diff --git a/core/bin/prover/src/dummy_prover.rs b/core/bin/prover/src/dummy_prover.rs index 4131e24fdb..fff60e2305 100644 --- a/core/bin/prover/src/dummy_prover.rs +++ b/core/bin/prover/src/dummy_prover.rs @@ -22,16 +22,14 @@ impl ProverConfig for DummyProverConfig { #[derive(Debug)] pub struct DummyProver { - config: DummyProverConfig, precomputed_proofs: PrecomputedSampleProofs, } impl ProverImpl for DummyProver { type Config = DummyProverConfig; - fn create_from_config(config: Self::Config) -> Self { + fn create_from_config(_config: Self::Config) -> Self { Self { - config, precomputed_proofs: load_precomputed_proofs() .expect("Failed to load precomputed proofs"), } diff --git a/core/bin/prover/tests/tests.rs b/core/bin/prover/tests/tests.rs index 8896bc95d0..70a586830f 100644 --- a/core/bin/prover/tests/tests.rs +++ b/core/bin/prover/tests/tests.rs @@ -102,7 +102,7 @@ fn test_data_for_prover() -> JobRequestData { account_id: empty_account_id, }; - let deposit_witness = DepositWitness::apply_tx(&mut witness_accum.account_tree, &deposit_op); + let deposit_witness = DepositWitness::apply_tx(witness_accum.account_tree, &deposit_op); let deposit_operations = deposit_witness.calculate_operations(()); let pub_data_from_witness = deposit_witness.get_pubdata(); let offset_commitment = deposit_witness.get_offset_commitment_data(); diff --git a/core/bin/zksync_api/src/api_server/rest/v02/test_utils.rs b/core/bin/zksync_api/src/api_server/rest/v02/test_utils.rs index 4815124ea0..26a3f5d1d5 100644 --- a/core/bin/zksync_api/src/api_server/rest/v02/test_utils.rs +++ b/core/bin/zksync_api/src/api_server/rest/v02/test_utils.rs @@ -503,7 +503,7 @@ impl TestServerConfig { if *block_number <= VERIFIED_BLOCKS_COUNT { // Add jobs to `job_prover_queue`. let job_data = serde_json::Value::default(); - ProverSchema(&mut storage) + ProverSchema(storage) .add_prover_job_to_job_queue( block_number, block_number, @@ -512,7 +512,7 @@ impl TestServerConfig { ProverJobType::SingleProof, ) .await?; - ProverSchema(&mut storage) + ProverSchema(storage) .add_prover_job_to_job_queue( block_number, block_number, @@ -523,12 +523,12 @@ impl TestServerConfig { .await?; // Get job id. - let stored_job_id = ProverSchema(&mut storage) + let stored_job_id = ProverSchema(storage) .get_idle_prover_job_from_job_queue() .await? .unwrap() .job_id; - let stored_aggregated_job_id = ProverSchema(&mut storage) + let stored_aggregated_job_id = ProverSchema(storage) .get_idle_prover_job_from_job_queue() .await? .unwrap() @@ -537,10 +537,10 @@ impl TestServerConfig { // Store proofs. let proof = get_sample_single_proof(); let aggregated_proof = get_sample_aggregated_proof(); - ProverSchema(&mut storage) + ProverSchema(storage) .store_proof(stored_job_id, block_number, &proof) .await?; - ProverSchema(&mut storage) + ProverSchema(storage) .store_aggregated_proof( stored_aggregated_job_id, block_number, diff --git a/core/bin/zksync_api/src/api_server/rpc_server/mod.rs b/core/bin/zksync_api/src/api_server/rpc_server/mod.rs index 257a9e8258..23aefc6bb7 100644 --- a/core/bin/zksync_api/src/api_server/rpc_server/mod.rs +++ b/core/bin/zksync_api/src/api_server/rpc_server/mod.rs @@ -41,8 +41,6 @@ use super::tx_sender::TxSender; #[derive(Clone)] pub struct RpcApp { - runtime_handle: tokio::runtime::Handle, - cache_of_executed_priority_operations: AsyncLruCache, cache_of_transaction_receipts: AsyncLruCache, TxReceiptResponse>, cache_of_complete_withdrawal_tx_hashes: AsyncLruCache, @@ -61,9 +59,6 @@ impl RpcApp { private_url: String, confirmations_for_eth_event: u64, ) -> Self { - let runtime_handle = tokio::runtime::Handle::try_current() - .expect("RpcApp must be created from the context of Tokio Runtime"); - let api_requests_caches_size = config.caches_size; let tx_sender = TxSender::new( @@ -75,8 +70,6 @@ impl RpcApp { ); RpcApp { - runtime_handle, - cache_of_executed_priority_operations: AsyncLruCache::new(api_requests_caches_size), cache_of_transaction_receipts: AsyncLruCache::new(api_requests_caches_size), cache_of_complete_withdrawal_tx_hashes: AsyncLruCache::new(api_requests_caches_size), diff --git a/core/bin/zksync_api/src/api_server/web3/mod.rs b/core/bin/zksync_api/src/api_server/web3/mod.rs index 898ca6b219..92820b3228 100644 --- a/core/bin/zksync_api/src/api_server/web3/mod.rs +++ b/core/bin/zksync_api/src/api_server/web3/mod.rs @@ -27,7 +27,6 @@ pub const NFT_FACTORY_ADDRESS: &str = "2000000000000000000000000000000000000000" #[derive(Clone)] pub struct Web3RpcApp { - runtime_handle: tokio::runtime::Handle, connection_pool: ConnectionPool, logs_helper: LogsHelper, calls_helper: CallsHelper, @@ -37,10 +36,7 @@ pub struct Web3RpcApp { impl Web3RpcApp { pub fn new(connection_pool: ConnectionPool, config: &Web3Config) -> Self { - let runtime_handle = tokio::runtime::Handle::try_current() - .expect("Web3RpcApp must be created from the context of Tokio Runtime"); Web3RpcApp { - runtime_handle, connection_pool, logs_helper: LogsHelper::new(), calls_helper: CallsHelper::new(), diff --git a/core/bin/zksync_api/src/fee_ticker/ticker_api/mod.rs b/core/bin/zksync_api/src/fee_ticker/ticker_api/mod.rs index 7aeff522d0..82ce3d46f5 100644 --- a/core/bin/zksync_api/src/fee_ticker/ticker_api/mod.rs +++ b/core/bin/zksync_api/src/fee_ticker/ticker_api/mod.rs @@ -45,15 +45,11 @@ pub trait FeeTickerAPI { #[derive(Debug, Clone)] pub(crate) struct TokenCacheEntry { price: TokenPrice, - creation_time: Instant, } impl TokenCacheEntry { - fn new(price: TokenPrice, creation_time: Instant) -> Self { - Self { - price, - creation_time, - } + fn new(price: TokenPrice) -> Self { + Self { price } } fn is_cache_entry_expired(&self) -> bool { @@ -135,10 +131,10 @@ impl TickerApi { } async fn update_stored_value(&self, token_id: TokenId, price: TokenPrice) { - self.price_cache.lock().await.insert( - token_id, - TokenCacheEntry::new(price.clone(), Instant::now()), - ); + self.price_cache + .lock() + .await + .insert(token_id, TokenCacheEntry::new(price.clone())); self._update_stored_value(token_id, price) .await .map_err(|e| vlog::warn!("Failed to update historical ticker price: {}", e)) diff --git a/core/lib/circuit/src/circuit.rs b/core/lib/circuit/src/circuit.rs index 7d9588ff94..9bdcaf62b7 100644 --- a/core/lib/circuit/src/circuit.rs +++ b/core/lib/circuit/src/circuit.rs @@ -772,7 +772,7 @@ impl<'a, E: RescueEngine + JubjubEngine> ZkSyncCircuit<'a, E> { fn execute_op>( &self, mut cs: CS, - mut cur: &mut AllocatedOperationBranch, + cur: &mut AllocatedOperationBranch, lhs: &AllocatedOperationBranch, rhs: &AllocatedOperationBranch, op: &Operation, @@ -1026,7 +1026,7 @@ impl<'a, E: RescueEngine + JubjubEngine> ZkSyncCircuit<'a, E> { let op_flags = vec![ self.deposit( cs.namespace(|| "deposit"), - &mut cur, + cur, global_variables, is_account_empty, &op_data, @@ -1035,7 +1035,7 @@ impl<'a, E: RescueEngine + JubjubEngine> ZkSyncCircuit<'a, E> { )?, self.transfer( cs.namespace(|| "transfer"), - &mut cur, + cur, lhs, rhs, global_variables, @@ -1053,7 +1053,7 @@ impl<'a, E: RescueEngine + JubjubEngine> ZkSyncCircuit<'a, E> { )?, self.transfer_to_new( cs.namespace(|| "transfer_to_new"), - &mut cur, + cur, lhs, rhs, global_variables, @@ -1071,7 +1071,7 @@ impl<'a, E: RescueEngine + JubjubEngine> ZkSyncCircuit<'a, E> { )?, self.withdraw( cs.namespace(|| "withdraw"), - &mut cur, + cur, global_variables, &is_a_geq_b, &op_data, @@ -1087,7 +1087,7 @@ impl<'a, E: RescueEngine + JubjubEngine> ZkSyncCircuit<'a, E> { // Close disable. // self.close_account( // cs.namespace(|| "close_account"), - // &mut cur, + // cur, // &chunk_data, // &ext_pubdata_chunk, // &op_data, @@ -1098,7 +1098,7 @@ impl<'a, E: RescueEngine + JubjubEngine> ZkSyncCircuit<'a, E> { // )?, self.full_exit( cs.namespace(|| "full_exit"), - &mut cur, + cur, global_variables, &op_data, ext_pubdata_chunk, @@ -1111,7 +1111,7 @@ impl<'a, E: RescueEngine + JubjubEngine> ZkSyncCircuit<'a, E> { self.change_pubkey_offchain( cs.namespace(|| "change_pubkey_offchain"), lhs, - &mut cur, + cur, global_variables, &op_data, ext_pubdata_chunk, @@ -1133,7 +1133,7 @@ impl<'a, E: RescueEngine + JubjubEngine> ZkSyncCircuit<'a, E> { )?, self.forced_exit( cs.namespace(|| "forced_exit"), - &mut cur, + cur, lhs, rhs, global_variables, @@ -1151,7 +1151,7 @@ impl<'a, E: RescueEngine + JubjubEngine> ZkSyncCircuit<'a, E> { )?, self.mint_nft( cs.namespace(|| "mint_nft"), - &mut cur, + cur, global_variables, &is_a_geq_b, is_account_empty, @@ -1166,7 +1166,7 @@ impl<'a, E: RescueEngine + JubjubEngine> ZkSyncCircuit<'a, E> { )?, self.withdraw_nft( cs.namespace(|| "withdraw_nft"), - &mut cur, + cur, global_variables, &is_a_geq_b, &op_data, @@ -1181,7 +1181,7 @@ impl<'a, E: RescueEngine + JubjubEngine> ZkSyncCircuit<'a, E> { )?, self.swap( cs.namespace(|| "swap"), - &mut cur, + cur, global_variables, &is_a_geq_b, is_account_empty, diff --git a/core/lib/circuit/src/playground/plonk_playground.rs b/core/lib/circuit/src/playground/plonk_playground.rs index 96af6fc559..c17a2dad1a 100644 --- a/core/lib/circuit/src/playground/plonk_playground.rs +++ b/core/lib/circuit/src/playground/plonk_playground.rs @@ -35,7 +35,7 @@ fn test_transpile_deposit_franklin_existing_account() { plasma_state.apply_deposit_op(&deposit_op); - let deposit_witness = DepositWitness::apply_tx(&mut witness_accum.account_tree, &deposit_op); + let deposit_witness = DepositWitness::apply_tx(witness_accum.account_tree, &deposit_op); let deposit_operations = deposit_witness.calculate_operations(()); let pub_data_from_witness = deposit_witness.get_pubdata(); @@ -225,8 +225,7 @@ fn test_new_transpile_deposit_franklin_existing_account() { for _ in 0..NUM_DEPOSITS { plasma_state.apply_deposit_op(&deposit_op); - let deposit_witness = - DepositWitness::apply_tx(&mut witness_accum.account_tree, &deposit_op); + let deposit_witness = DepositWitness::apply_tx(witness_accum.account_tree, &deposit_op); let deposit_operations = deposit_witness.calculate_operations(()); let pub_data_from_witness = deposit_witness.get_pubdata(); @@ -400,8 +399,7 @@ fn test_fma_transpile_deposit_franklin_existing_account() { for _ in 0..NUM_DEPOSITS { plasma_state.apply_deposit_op(&deposit_op); - let deposit_witness = - DepositWitness::apply_tx(&mut witness_accum.account_tree, &deposit_op); + let deposit_witness = DepositWitness::apply_tx(witness_accum.account_tree, &deposit_op); let deposit_operations = deposit_witness.calculate_operations(()); let pub_data_from_witness = deposit_witness.get_pubdata(); diff --git a/core/lib/circuit/src/witness/tests/full_exit.rs b/core/lib/circuit/src/witness/tests/full_exit.rs index 335c2996d4..062d509595 100644 --- a/core/lib/circuit/src/witness/tests/full_exit.rs +++ b/core/lib/circuit/src/witness/tests/full_exit.rs @@ -126,7 +126,7 @@ fn apply_nft_mint_and_full_exit_nft_operations() -> ZkSyncCircuit<'static, Bn256 .unwrap(); fees.push(fee); - let witness = MintNFTWitness::apply_tx(&mut witness_accum.account_tree, &mint_nft_op); + let witness = MintNFTWitness::apply_tx(witness_accum.account_tree, &mint_nft_op); let circuit_operations = witness.calculate_operations(mint_nft_input); let pub_data_from_witness = witness.get_pubdata(); let offset_commitment = witness.get_offset_commitment_data(); @@ -142,7 +142,7 @@ fn apply_nft_mint_and_full_exit_nft_operations() -> ZkSyncCircuit<'static, Bn256 .expect("Operation failed"); let witness = FullExitWitness::apply_tx( - &mut witness_accum.account_tree, + witness_accum.account_tree, &(full_exit_op, full_exit_sucess), ); let circuit_operations = witness.calculate_operations(()); diff --git a/core/lib/circuit/src/witness/tests/mod.rs b/core/lib/circuit/src/witness/tests/mod.rs index 905fa955c2..e7c7f00d26 100644 --- a/core/lib/circuit/src/witness/tests/mod.rs +++ b/core/lib/circuit/src/witness/tests/mod.rs @@ -233,7 +233,7 @@ fn apply_many_ops() -> ZkSyncCircuit<'static, Bn256> { >::apply_op(&mut plasma_state, &deposit_op) .expect("Deposit failed"); - let witness = DepositWitness::apply_tx(&mut witness_accum.account_tree, &deposit_op); + let witness = DepositWitness::apply_tx(witness_accum.account_tree, &deposit_op); let circuit_operations = witness.calculate_operations(()); let pub_data_from_witness = witness.get_pubdata(); let offset_commitment = witness.get_offset_commitment_data(); @@ -253,7 +253,7 @@ fn apply_many_ops() -> ZkSyncCircuit<'static, Bn256> { .unwrap(); fees.push(fee); - let witness = TransferWitness::apply_tx(&mut witness_accum.account_tree, &transfer_op); + let witness = TransferWitness::apply_tx(witness_accum.account_tree, &transfer_op); let circuit_operations = witness.calculate_operations(transfer_input); let pub_data_from_witness = witness.get_pubdata(); let offset_commitment = witness.get_offset_commitment_data(); @@ -272,8 +272,7 @@ fn apply_many_ops() -> ZkSyncCircuit<'static, Bn256> { .unwrap(); fees.push(fee); - let witness = - TransferToNewWitness::apply_tx(&mut witness_accum.account_tree, &transfer_to_new_op); + let witness = TransferToNewWitness::apply_tx(witness_accum.account_tree, &transfer_to_new_op); let circuit_operations = witness.calculate_operations(transfer_to_new_input); let pub_data_from_witness = witness.get_pubdata(); let offset_commitment = witness.get_offset_commitment_data(); @@ -291,7 +290,7 @@ fn apply_many_ops() -> ZkSyncCircuit<'static, Bn256> { .unwrap(); fees.push(fee); - let witness = WithdrawWitness::apply_tx(&mut witness_accum.account_tree, &withdraw_op); + let witness = WithdrawWitness::apply_tx(witness_accum.account_tree, &withdraw_op); let circuit_operations = witness.calculate_operations(withdraw_input); let pub_data_from_witness = witness.get_pubdata(); let offset_commitment = witness.get_offset_commitment_data(); @@ -308,7 +307,7 @@ fn apply_many_ops() -> ZkSyncCircuit<'static, Bn256> { .expect("Operation failed"); let witness = FullExitWitness::apply_tx( - &mut witness_accum.account_tree, + witness_accum.account_tree, &(full_exit_op, full_exit_success), ); let circuit_operations = witness.calculate_operations(()); @@ -328,7 +327,7 @@ fn apply_many_ops() -> ZkSyncCircuit<'static, Bn256> { .unwrap(); fees.push(fee); - let witness = MintNFTWitness::apply_tx(&mut witness_accum.account_tree, &mint_nft_op); + let witness = MintNFTWitness::apply_tx(witness_accum.account_tree, &mint_nft_op); let circuit_operations = witness.calculate_operations(mint_nft_input); let pub_data_from_witness = witness.get_pubdata(); let offset_commitment = witness.get_offset_commitment_data(); @@ -347,7 +346,7 @@ fn apply_many_ops() -> ZkSyncCircuit<'static, Bn256> { .unwrap(); fees.push(fee); - let witness = WithdrawNFTWitness::apply_tx(&mut witness_accum.account_tree, &withdraw_nft_op); + let witness = WithdrawNFTWitness::apply_tx(witness_accum.account_tree, &withdraw_nft_op); let circuit_operations = witness.calculate_operations(withdraw_nft_input); let pub_data_from_witness = witness.get_pubdata(); let offset_commitment = witness.get_offset_commitment_data(); diff --git a/core/lib/circuit/src/witness/tests/test_utils.rs b/core/lib/circuit/src/witness/tests/test_utils.rs index ef39fbec8d..54223df74b 100644 --- a/core/lib/circuit/src/witness/tests/test_utils.rs +++ b/core/lib/circuit/src/witness/tests/test_utils.rs @@ -168,7 +168,7 @@ pub fn generic_test_scenario( plasma_state.collect_fee(&fees, FEE_ACCOUNT_ID); // Apply op on circuit - let witness = W::apply_tx(&mut witness_accum.account_tree, &op); + let witness = W::apply_tx(witness_accum.account_tree, &op); let circuit_operations = witness.calculate_operations(input); let pub_data_from_witness = witness.get_pubdata(); let offset_commitment = witness.get_offset_commitment_data(); @@ -225,7 +225,7 @@ pub fn corrupted_input_test_scenario( plasma_state.collect_fee(&fees, FEE_ACCOUNT_ID); // Apply op on circuit - let witness = W::apply_tx(&mut witness_accum.account_tree, &op); + let witness = W::apply_tx(witness_accum.account_tree, &op); let circuit_operations = witness.calculate_operations(input.clone()); let pub_data_from_witness = witness.get_pubdata(); let offset_commitment = witness.get_offset_commitment_data(); @@ -292,7 +292,7 @@ pub fn incorrect_op_test_scenario( let fees = collect_fees(); // Apply op on circuit - let witness = W::apply_tx(&mut witness_accum.account_tree, &op); + let witness = W::apply_tx(witness_accum.account_tree, &op); let circuit_operations = witness.calculate_operations(input.clone()); let pub_data_from_witness = witness.get_pubdata(); let offset_commitment = witness.get_offset_commitment_data(); diff --git a/core/lib/circuit/src/witness/tests/withdraw_nft.rs b/core/lib/circuit/src/witness/tests/withdraw_nft.rs index d477a8858f..efaf222354 100644 --- a/core/lib/circuit/src/witness/tests/withdraw_nft.rs +++ b/core/lib/circuit/src/witness/tests/withdraw_nft.rs @@ -97,7 +97,7 @@ fn apply_nft_mint_and_withdraw_operations() -> ZkSyncCircuit<'static, Bn256> { .unwrap(); fees.push(fee); - let witness = MintNFTWitness::apply_tx(&mut witness_accum.account_tree, &mint_nft_op); + let witness = MintNFTWitness::apply_tx(witness_accum.account_tree, &mint_nft_op); let circuit_operations = witness.calculate_operations(mint_nft_input); let pub_data_from_witness = witness.get_pubdata(); let offset_commitment = witness.get_offset_commitment_data(); @@ -116,7 +116,7 @@ fn apply_nft_mint_and_withdraw_operations() -> ZkSyncCircuit<'static, Bn256> { .unwrap(); fees.push(fee); - let witness = WithdrawNFTWitness::apply_tx(&mut witness_accum.account_tree, &withdraw_nft_op); + let witness = WithdrawNFTWitness::apply_tx(witness_accum.account_tree, &withdraw_nft_op); let circuit_operations = witness.calculate_operations(withdraw_nft_input); let pub_data_from_witness = witness.get_pubdata(); let offset_commitment = witness.get_offset_commitment_data(); @@ -283,7 +283,7 @@ fn test_withdraw_nft_with_zero_balance() { let mut witness_accum = WitnessBuilder::new(&mut circuit_account_tree, FEE_ACCOUNT_ID, BlockNumber(1), 0); - let witness = MintNFTWitness::apply_tx(&mut witness_accum.account_tree, &mint_nft_op); + let witness = MintNFTWitness::apply_tx(witness_accum.account_tree, &mint_nft_op); let circuit_operations = witness.calculate_operations(mint_nft_input); let pub_data_from_witness = witness.get_pubdata(); let offset_commitment = witness.get_offset_commitment_data(); @@ -294,7 +294,7 @@ fn test_withdraw_nft_with_zero_balance() { offset_commitment, ); - let witness = WithdrawNFTWitness::apply_tx(&mut witness_accum.account_tree, &withdraw_nft_op); + let witness = WithdrawNFTWitness::apply_tx(witness_accum.account_tree, &withdraw_nft_op); let circuit_operations = witness.calculate_operations(withdraw_nft_input); let pub_data_from_witness = witness.get_pubdata(); let offset_commitment = witness.get_offset_commitment_data(); @@ -398,7 +398,7 @@ fn test_withdraw_nft_corrupted_ops_input() { let mut witness_accum = WitnessBuilder::new(&mut circuit_account_tree, FEE_ACCOUNT_ID, BlockNumber(1), 0); - let witness = MintNFTWitness::apply_tx(&mut witness_accum.account_tree, &mint_nft_op); + let witness = MintNFTWitness::apply_tx(witness_accum.account_tree, &mint_nft_op); let circuit_operations = witness.calculate_operations(mint_nft_input.clone()); let pub_data_from_witness = witness.get_pubdata(); let offset_commitment = witness.get_offset_commitment_data(); @@ -409,8 +409,7 @@ fn test_withdraw_nft_corrupted_ops_input() { offset_commitment, ); - let witness = - WithdrawNFTWitness::apply_tx(&mut witness_accum.account_tree, &withdraw_nft_op); + let witness = WithdrawNFTWitness::apply_tx(witness_accum.account_tree, &withdraw_nft_op); let circuit_operations = witness.calculate_operations(withdraw_nft_corrupted_input); let pub_data_from_witness = witness.get_pubdata(); let offset_commitment = witness.get_offset_commitment_data(); diff --git a/core/lib/circuit/src/witness/utils.rs b/core/lib/circuit/src/witness/utils.rs index 22ecca4226..9a25c9c524 100644 --- a/core/lib/circuit/src/witness/utils.rs +++ b/core/lib/circuit/src/witness/utils.rs @@ -173,10 +173,10 @@ impl<'a> WitnessBuilder<'a> { .to_vec(), ); let (mut root_after_fee, mut fee_account_witness) = - crate::witness::utils::apply_fee(&mut self.account_tree, *self.fee_account_id, 0, 0); + crate::witness::utils::apply_fee(self.account_tree, *self.fee_account_id, 0, 0); for CollectedFee { token, amount } in fees { let (root, acc_witness) = crate::witness::utils::apply_fee( - &mut self.account_tree, + self.account_tree, *self.fee_account_id, **token as u32, amount.to_u128().unwrap(), @@ -765,7 +765,7 @@ pub fn build_block_witness<'a>( match op { ZkSyncOp::Deposit(deposit) => { let deposit_witness = - DepositWitness::apply_tx(&mut witness_accum.account_tree, &deposit); + DepositWitness::apply_tx(witness_accum.account_tree, &deposit); let deposit_operations = deposit_witness.calculate_operations(()); operations.extend(deposit_operations); @@ -774,7 +774,7 @@ pub fn build_block_witness<'a>( } ZkSyncOp::Transfer(transfer) => { let transfer_witness = - TransferWitness::apply_tx(&mut witness_accum.account_tree, &transfer); + TransferWitness::apply_tx(witness_accum.account_tree, &transfer); let input = SigDataInput::from_transfer_op(&transfer)?; let transfer_operations = transfer_witness.calculate_operations(input); @@ -788,10 +788,8 @@ pub fn build_block_witness<'a>( offset_commitment.extend(transfer_witness.get_offset_commitment_data()) } ZkSyncOp::TransferToNew(transfer_to_new) => { - let transfer_to_new_witness = TransferToNewWitness::apply_tx( - &mut witness_accum.account_tree, - &transfer_to_new, - ); + let transfer_to_new_witness = + TransferToNewWitness::apply_tx(witness_accum.account_tree, &transfer_to_new); let input = SigDataInput::from_transfer_to_new_op(&transfer_to_new)?; let transfer_to_new_operations = @@ -807,7 +805,7 @@ pub fn build_block_witness<'a>( } ZkSyncOp::Withdraw(withdraw) => { let withdraw_witness = - WithdrawWitness::apply_tx(&mut witness_accum.account_tree, &withdraw); + WithdrawWitness::apply_tx(witness_accum.account_tree, &withdraw); let input = SigDataInput::from_withdraw_op(&withdraw)?; let withdraw_operations = withdraw_witness.calculate_operations(input); @@ -822,7 +820,7 @@ pub fn build_block_witness<'a>( } ZkSyncOp::Close(close) => { let close_account_witness = - CloseAccountWitness::apply_tx(&mut witness_accum.account_tree, &close); + CloseAccountWitness::apply_tx(witness_accum.account_tree, &close); let input = SigDataInput::from_close_op(&close)?; let close_account_operations = close_account_witness.calculate_operations(input); @@ -835,7 +833,7 @@ pub fn build_block_witness<'a>( let success = full_exit_op.withdraw_amount.is_some(); let full_exit_witness = FullExitWitness::apply_tx( - &mut witness_accum.account_tree, + witness_accum.account_tree, &(*full_exit_op, success), ); @@ -847,7 +845,7 @@ pub fn build_block_witness<'a>( } ZkSyncOp::ChangePubKeyOffchain(change_pkhash_op) => { let change_pkhash_witness = ChangePubkeyOffChainWitness::apply_tx( - &mut witness_accum.account_tree, + witness_accum.account_tree, &change_pkhash_op, ); @@ -864,7 +862,7 @@ pub fn build_block_witness<'a>( } ZkSyncOp::ForcedExit(forced_exit) => { let forced_exit_witness = - ForcedExitWitness::apply_tx(&mut witness_accum.account_tree, &forced_exit); + ForcedExitWitness::apply_tx(witness_accum.account_tree, &forced_exit); let input = SigDataInput::from_forced_exit_op(&forced_exit)?; let forced_exit_operations = forced_exit_witness.calculate_operations(input); @@ -878,7 +876,7 @@ pub fn build_block_witness<'a>( offset_commitment.extend(forced_exit_witness.get_offset_commitment_data()) } ZkSyncOp::Swap(swap) => { - let swap_witness = SwapWitness::apply_tx(&mut witness_accum.account_tree, &swap); + let swap_witness = SwapWitness::apply_tx(witness_accum.account_tree, &swap); let input = ( SigDataInput::from_order(&swap.tx.orders.0)?, @@ -899,7 +897,7 @@ pub fn build_block_witness<'a>( ZkSyncOp::Noop(_) => {} // Noops are handled below ZkSyncOp::MintNFTOp(mint_nft) => { let mint_nft_witness = - MintNFTWitness::apply_tx(&mut witness_accum.account_tree, &mint_nft); + MintNFTWitness::apply_tx(witness_accum.account_tree, &mint_nft); let input = SigDataInput::from_mint_nft_op(&mint_nft)?; let mint_nft_operations = mint_nft_witness.calculate_operations(input); @@ -914,7 +912,7 @@ pub fn build_block_witness<'a>( } ZkSyncOp::WithdrawNFT(withdraw_nft) => { let withdraw_nft_witness = - WithdrawNFTWitness::apply_tx(&mut witness_accum.account_tree, &withdraw_nft); + WithdrawNFTWitness::apply_tx(witness_accum.account_tree, &withdraw_nft); let input = SigDataInput::from_withdraw_nft_op(&withdraw_nft)?; let withdraw_nft_operations = withdraw_nft_witness.calculate_operations(input); diff --git a/core/lib/crypto/src/merkle_tree/parallel_smt.rs b/core/lib/crypto/src/merkle_tree/parallel_smt.rs index a1e6511a3d..69aa881b36 100644 --- a/core/lib/crypto/src/merkle_tree/parallel_smt.rs +++ b/core/lib/crypto/src/merkle_tree/parallel_smt.rs @@ -732,18 +732,12 @@ where mod tests { use super::*; - #[derive(Debug)] + #[derive(Debug, Default)] struct TestHasher; - #[derive(Debug, PartialEq)] + #[derive(Debug, PartialEq, Default)] struct TestLeaf(u64); - impl Default for TestLeaf { - fn default() -> Self { - TestLeaf(0) - } - } - impl GetBits for TestLeaf { fn get_bits_le(&self) -> Vec { let mut acc = Vec::new(); @@ -756,12 +750,6 @@ mod tests { } } - impl Default for TestHasher { - fn default() -> Self { - Self {} - } - } - impl Hasher for TestHasher { fn hash_bits>(&self, value: I) -> u64 { let mut acc = 0; diff --git a/core/lib/prover_utils/src/api.rs b/core/lib/prover_utils/src/api.rs index c0a326d64b..5b4f0cfd2b 100644 --- a/core/lib/prover_utils/src/api.rs +++ b/core/lib/prover_utils/src/api.rs @@ -24,6 +24,7 @@ pub struct ProverInputResponse { } #[derive(Clone, Debug, Serialize, Deserialize)] +#[allow(clippy::large_enum_variant)] pub enum JobRequestData { BlockProof( ProverData, diff --git a/core/lib/storage/src/tests/chain/operations_ext/mod.rs b/core/lib/storage/src/tests/chain/operations_ext/mod.rs index e2e53a7264..967bc3baba 100644 --- a/core/lib/storage/src/tests/chain/operations_ext/mod.rs +++ b/core/lib/storage/src/tests/chain/operations_ext/mod.rs @@ -130,7 +130,7 @@ pub async fn commit_block( ) -> QueryResult<()> { // Required since we use `EthereumSchema` in this test. storage.ethereum_schema().initialize_eth_data().await?; - BlockSchema(&mut storage) + BlockSchema(storage) .save_block(gen_sample_block( block_number, BLOCK_SIZE_CHUNKS, diff --git a/core/lib/storage/src/tests/prover.rs b/core/lib/storage/src/tests/prover.rs index f756e66c0f..e8b5707616 100644 --- a/core/lib/storage/src/tests/prover.rs +++ b/core/lib/storage/src/tests/prover.rs @@ -15,7 +15,7 @@ use crate::{prover::ProverSchema, QueryResult, StorageProcessor}; static MUTEX: Lazy> = Lazy::new(|| Mutex::new(())); async fn get_idle_job_from_queue(mut storage: &mut StorageProcessor<'_>) -> QueryResult { - let job = ProverSchema(&mut storage) + let job = ProverSchema(storage) .get_idle_prover_job_from_job_queue() .await?; @@ -38,11 +38,11 @@ async fn test_prover_job_queue(mut storage: StorageProcessor<'_>) -> QueryResult /// Checks that the single and aggregated proof can be stored and loaded. async fn test_store_proof(mut storage: &mut StorageProcessor<'_>) -> QueryResult<()> { // Attempt to load the proof that was not stored should result in None. - let loaded_proof = ProverSchema(&mut storage) + let loaded_proof = ProverSchema(storage) .load_proof(BlockNumber(1)) .await .expect("Error while obtaining proof"); - let loaded_aggregated_proof = ProverSchema(&mut storage) + let loaded_aggregated_proof = ProverSchema(storage) .load_aggregated_proof(BlockNumber(1), BlockNumber(1)) .await .expect("Error while obtaining proof"); @@ -54,10 +54,10 @@ async fn test_store_proof(mut storage: &mut StorageProcessor<'_>) -> QueryResult let proof = get_sample_single_proof(); let aggregated_proof = get_sample_aggregated_proof(); - let stored_proof = ProverSchema(&mut storage) + let stored_proof = ProverSchema(storage) .store_proof(1, BlockNumber(1), &proof) .await; - let stored_aggregated_proof = ProverSchema(&mut storage) + let stored_aggregated_proof = ProverSchema(storage) .store_aggregated_proof(1, BlockNumber(1), BlockNumber(1), &aggregated_proof) .await; @@ -74,7 +74,7 @@ async fn test_store_proof(mut storage: &mut StorageProcessor<'_>) -> QueryResult // Add jobs to `job_prover_queue`. let job_data = serde_json::Value::default(); - let stored_job = ProverSchema(&mut storage) + let stored_job = ProverSchema(storage) .add_prover_job_to_job_queue( BlockNumber(1), BlockNumber(1), @@ -83,7 +83,7 @@ async fn test_store_proof(mut storage: &mut StorageProcessor<'_>) -> QueryResult ProverJobType::SingleProof, ) .await; - let stored_aggregated_job = ProverSchema(&mut storage) + let stored_aggregated_job = ProverSchema(storage) .add_prover_job_to_job_queue( BlockNumber(1), BlockNumber(1), @@ -101,10 +101,10 @@ async fn test_store_proof(mut storage: &mut StorageProcessor<'_>) -> QueryResult let stored_aggregated_job_id = get_idle_job_from_queue(&mut storage).await?.job_id; // Store proofs. - let stored_proof = ProverSchema(&mut storage) + let stored_proof = ProverSchema(storage) .store_proof(stored_job_id, BlockNumber(1), &proof) .await; - let stored_aggregated_proof = ProverSchema(&mut storage) + let stored_aggregated_proof = ProverSchema(storage) .store_aggregated_proof( stored_aggregated_job_id, BlockNumber(1), @@ -117,10 +117,8 @@ async fn test_store_proof(mut storage: &mut StorageProcessor<'_>) -> QueryResult assert!(stored_aggregated_proof.is_ok()); // Now load it. - let loaded_proof = ProverSchema(&mut storage) - .load_proof(BlockNumber(1)) - .await?; - let loaded_aggregated_proof = ProverSchema(&mut storage) + let loaded_proof = ProverSchema(storage).load_proof(BlockNumber(1)).await?; + let loaded_aggregated_proof = ProverSchema(storage) .load_aggregated_proof(BlockNumber(1), BlockNumber(1)) .await?; @@ -134,11 +132,11 @@ async fn test_store_proof(mut storage: &mut StorageProcessor<'_>) -> QueryResult /// of jobs for which proof is not generating (or generated) yet. async fn pending_jobs_count(mut storage: &mut StorageProcessor<'_>) -> QueryResult<()> { // Initially there are no jobs. - let jobs_count = ProverSchema(&mut storage).pending_jobs_count().await?; + let jobs_count = ProverSchema(storage).pending_jobs_count().await?; assert_eq!(jobs_count, 0); // Create a some jobs. - ProverSchema(&mut storage) + ProverSchema(storage) .add_prover_job_to_job_queue( BlockNumber(2), BlockNumber(2), @@ -147,7 +145,7 @@ async fn pending_jobs_count(mut storage: &mut StorageProcessor<'_>) -> QueryResu ProverJobType::SingleProof, ) .await?; - ProverSchema(&mut storage) + ProverSchema(storage) .add_prover_job_to_job_queue( BlockNumber(3), BlockNumber(3), @@ -156,7 +154,7 @@ async fn pending_jobs_count(mut storage: &mut StorageProcessor<'_>) -> QueryResu ProverJobType::SingleProof, ) .await?; - ProverSchema(&mut storage) + ProverSchema(storage) .add_prover_job_to_job_queue( BlockNumber(2), BlockNumber(3), @@ -167,49 +165,49 @@ async fn pending_jobs_count(mut storage: &mut StorageProcessor<'_>) -> QueryResu .await?; // We've created 3 jobs and no jobs were assigned yet. - let jobs_count = ProverSchema(&mut storage).pending_jobs_count().await?; + let jobs_count = ProverSchema(storage).pending_jobs_count().await?; assert_eq!(jobs_count, 3); let first_job = get_idle_job_from_queue(&mut storage).await?; - let jobs_count = ProverSchema(&mut storage).pending_jobs_count().await?; + let jobs_count = ProverSchema(storage).pending_jobs_count().await?; assert_eq!(jobs_count, 3); // Create next run & repeat checks. let second_job = get_idle_job_from_queue(&mut storage).await?; - let jobs_count = ProverSchema(&mut storage).pending_jobs_count().await?; + let jobs_count = ProverSchema(storage).pending_jobs_count().await?; assert_eq!(jobs_count, 3); let third_job = get_idle_job_from_queue(&mut storage).await?; - let jobs_count = ProverSchema(&mut storage).pending_jobs_count().await?; + let jobs_count = ProverSchema(storage).pending_jobs_count().await?; assert_eq!(jobs_count, 3); // Record prover is working and stopped it. - ProverSchema(&mut storage) + ProverSchema(storage) .record_prover_is_working(first_job.job_id, "test_prover") .await?; - ProverSchema(&mut storage) + ProverSchema(storage) .record_prover_is_working(second_job.job_id, "test_prover") .await?; - ProverSchema(&mut storage) + ProverSchema(storage) .record_prover_is_working(third_job.job_id, "test_prover") .await?; // Store one proof and then turn off the prover. - ProverSchema(&mut storage) + ProverSchema(storage) .store_proof( third_job.job_id, third_job.first_block, &get_sample_single_proof(), ) .await?; - let jobs_count = ProverSchema(&mut storage).pending_jobs_count().await?; + let jobs_count = ProverSchema(storage).pending_jobs_count().await?; assert_eq!(jobs_count, 2); - ProverSchema(&mut storage) + ProverSchema(storage) .record_prover_stop("test_prover") .await?; - let jobs_count = ProverSchema(&mut storage).pending_jobs_count().await?; + let jobs_count = ProverSchema(storage).pending_jobs_count().await?; assert_eq!(jobs_count, 2); Ok(()) diff --git a/core/lib/types/src/aggregated_operations.rs b/core/lib/types/src/aggregated_operations.rs index fe936afb2c..ffda873faf 100644 --- a/core/lib/types/src/aggregated_operations.rs +++ b/core/lib/types/src/aggregated_operations.rs @@ -82,7 +82,7 @@ pub struct BlocksProofOperation { impl BlocksProofOperation { pub fn get_eth_tx_args(&self) -> Vec { - let blocks_arg = Token::Array(self.blocks.iter().map(|b| stored_block_info(b)).collect()); + let blocks_arg = Token::Array(self.blocks.iter().map(stored_block_info).collect()); let proof = self.proof.get_eth_tx_args(); diff --git a/core/lib/types/src/register_factory.rs b/core/lib/types/src/register_factory.rs index 39c6f29aff..f5f34e9d2f 100644 --- a/core/lib/types/src/register_factory.rs +++ b/core/lib/types/src/register_factory.rs @@ -8,6 +8,7 @@ use zksync_basic_types::Log; use crate::Address; #[derive(Debug, Error)] +#[allow(clippy::large_enum_variant)] pub enum RegisterNFTFactoryEventParseError { #[error("Cannot parse log for Register Factory Event {0:?}")] ParseLogError(Log),