From ee2e516bed96e997c866e6c5441ee6c8e2907594 Mon Sep 17 00:00:00 2001 From: Evan Batsell Date: Fri, 13 Dec 2024 15:03:33 -0500 Subject: [PATCH] nit --- core/src/utils.rs | 56 +------------------ .../tests/fixtures/restaking_client.rs | 7 --- .../snapshot_vault_operator_delegation.rs | 6 -- 3 files changed, 1 insertion(+), 68 deletions(-) diff --git a/core/src/utils.rs b/core/src/utils.rs index 0962dcf..caa39ea 100644 --- a/core/src/utils.rs +++ b/core/src/utils.rs @@ -1,11 +1,4 @@ -use solana_program::{ - account_info::AccountInfo, - entrypoint::ProgramResult, - program::{invoke, invoke_signed}, - program_error::ProgramError, - rent::Rent, - system_instruction, -}; +use solana_program::program_error::ProgramError; use crate::constants::MAX_REALLOC_BYTES; @@ -17,50 +10,3 @@ pub fn get_new_size(current_size: usize, target_size: usize) -> Result( - account: &'a AccountInfo<'info>, - payer: &'a AccountInfo<'info>, - system_program: &'a AccountInfo<'info>, - rent: &Rent, - target_size: u64, - seeds: &[Vec], -) -> ProgramResult { - let current_size = account.data_len(); - - // If account is already over target size, don't try to shrink - if current_size >= target_size as usize { - return Ok(()); - } - - // Calculate new size, capped at target_size - let new_size = current_size - .checked_add(MAX_REALLOC_BYTES as usize) - .ok_or(ProgramError::ArithmeticOverflow)? - .min(target_size as usize); - - // Calculate required lamports for new size - let new_minimum_balance = rent.minimum_balance(new_size); - let lamports_diff = new_minimum_balance.saturating_sub(account.lamports()); - - // Transfer lamports if needed - if lamports_diff > 0 { - invoke( - &system_instruction::transfer(payer.key, account.key, lamports_diff), - &[payer.clone(), account.clone(), system_program.clone()], - )?; - } - - // Reallocate space - invoke_signed( - &system_instruction::allocate(account.key, new_size as u64), - &[account.clone(), system_program.clone()], - &[seeds - .iter() - .map(|seed| seed.as_slice()) - .collect::>() - .as_slice()], - )?; - - Ok(()) -} diff --git a/integration_tests/tests/fixtures/restaking_client.rs b/integration_tests/tests/fixtures/restaking_client.rs index fa50a83..4b1d7a0 100644 --- a/integration_tests/tests/fixtures/restaking_client.rs +++ b/integration_tests/tests/fixtures/restaking_client.rs @@ -89,13 +89,6 @@ impl RestakingProgramClient { Ok(*Config::try_from_slice_unchecked(account.data.as_slice())?) } - pub async fn get_ncn_epoch(&mut self, slot: u64) -> TestResult { - let restaking_config_address = - Config::find_program_address(&jito_restaking_program::id()).0; - let config = self.get_config(&restaking_config_address).await.unwrap(); - Ok(config.get_epoch_from_slot(slot).unwrap()) - } - #[allow(dead_code)] pub async fn get_ncn_vault_ticket( &mut self, diff --git a/integration_tests/tests/tip_router/snapshot_vault_operator_delegation.rs b/integration_tests/tests/tip_router/snapshot_vault_operator_delegation.rs index 2b3e4e9..ae7b1f2 100644 --- a/integration_tests/tests/tip_router/snapshot_vault_operator_delegation.rs +++ b/integration_tests/tests/tip_router/snapshot_vault_operator_delegation.rs @@ -21,12 +21,6 @@ mod tests { .do_full_initialize_weight_table(test_ncn.ncn_root.ncn_pubkey, epoch) .await?; - let weight_table_pda = WeightTable::find_program_address( - &jito_tip_router_program::id(), - &test_ncn.ncn_root.ncn_pubkey, - epoch, - ) - .0; let ncn = test_ncn.ncn_root.ncn_pubkey; let vault_root = test_ncn.vaults[0].clone();