From 1d20c0eba1bbf370744218ea3e1f4cef2598eb96 Mon Sep 17 00:00:00 2001 From: blockiosaurus Date: Sun, 25 Feb 2024 21:38:31 -0500 Subject: [PATCH] Removing debug prints. --- programs/mpl-core/src/plugins/transfer.rs | 3 - programs/mpl-core/src/plugins/utils.rs | 90 ------------------- programs/mpl-core/src/processor/burn.rs | 2 - programs/mpl-core/src/processor/transfer.rs | 2 - programs/mpl-core/src/processor/update.rs | 8 -- .../mpl-core/src/processor/update_plugin.rs | 1 - 6 files changed, 106 deletions(-) diff --git a/programs/mpl-core/src/plugins/transfer.rs b/programs/mpl-core/src/plugins/transfer.rs index 5e4f583a..41bf03bd 100644 --- a/programs/mpl-core/src/plugins/transfer.rs +++ b/programs/mpl-core/src/plugins/transfer.rs @@ -77,14 +77,11 @@ impl PluginValidation for Transfer { _args: &TransferArgs, authorities: &[Authority], ) -> Result { - solana_program::msg!("Validate Transfer for Transfer Plugin"); if authorities.contains(&Authority::Pubkey { address: *ctx.authority.key, }) { - solana_program::msg!("Approved"); Ok(ValidationResult::Approved) } else { - solana_program::msg!("Pass"); Ok(ValidationResult::Pass) } } diff --git a/programs/mpl-core/src/plugins/utils.rs b/programs/mpl-core/src/plugins/utils.rs index bc2e51b8..da5ad1c8 100644 --- a/programs/mpl-core/src/plugins/utils.rs +++ b/programs/mpl-core/src/plugins/utils.rs @@ -73,8 +73,6 @@ pub fn fetch_plugin( let PluginRegistry { registry, .. } = PluginRegistry::load(account, header.plugin_registry_offset)?; - solana_program::msg!("{:?}", registry); - // Find the plugin in the registry. let plugin_data = registry .iter() @@ -92,11 +90,9 @@ pub fn fetch_plugin( ) .ok_or(MplAssetError::PluginNotFound)?; - solana_program::msg!("Deserialize plugin at offset"); // Deserialize the plugin. let plugin = Plugin::deserialize(&mut &(*account.data).borrow()[plugin_data.offset..])?; - solana_program::msg!("Return plugin"); // Return the plugin and its authorities. Ok((plugin_data.authorities.clone(), plugin, plugin_data.offset)) } @@ -125,87 +121,6 @@ pub fn list_plugins(account: &AccountInfo) -> Result, ProgramErr .collect()) } -/// Add a plugin into the registry -// pub fn add_plugin_or_authority<'a>( -// plugin: &Plugin, -// authority: Authority, -// account: &AccountInfo<'a>, -// payer: &AccountInfo<'a>, -// system_program: &AccountInfo<'a>, -// ) -> ProgramResult { -// let asset = { -// let mut bytes: &[u8] = &(*account.data).borrow(); -// Asset::deserialize(&mut bytes)? -// }; - -// //TODO: Bytemuck this. -// let mut header = PluginHeader::load(account, asset.get_size())?; -// let mut plugin_registry = PluginRegistry::load(account, header.plugin_registry_offset)?; - -// let plugin_type = plugin.into(); -// let plugin_data = plugin.try_to_vec()?; -// let plugin_size = plugin_data.len(); -// let authority_bytes = authority.try_to_vec()?; - -// if let Some(RegistryRecord { -// plugin_type: _, -// data: registry_data, -// }) = plugin_registry.registry.iter_mut().find( -// |RegistryRecord { -// plugin_type: type_iter, -// data: _, -// }| type_iter == &plugin_type, -// ) { -// registry_data.authorities.push(authority.clone()); - -// let new_size = account -// .data_len() -// .checked_add(authority_bytes.len()) -// .ok_or(MplAssetError::NumericalOverflow)?; -// resize_or_reallocate_account_raw(account, payer, system_program, new_size)?; - -// plugin_registry.save(account, header.plugin_registry_offset)?; -// } else { -// let old_registry_offset = header.plugin_registry_offset; -// let registry_data = RegistryData { -// offset: old_registry_offset, -// authorities: vec![authority], -// }; - -// //TODO: There's probably a better way to get the size without having to serialize the registry data. -// let size_increase = plugin_size -// .checked_add(Key::get_initial_size()) -// .ok_or(MplAssetError::NumericalOverflow)? -// .checked_add(registry_data.clone().try_to_vec()?.len()) -// .ok_or(MplAssetError::NumericalOverflow)?; - -// let new_registry_offset = header -// .plugin_registry_offset -// .checked_add(plugin_size) -// .ok_or(MplAssetError::NumericalOverflow)?; - -// header.plugin_registry_offset = new_registry_offset; - -// plugin_registry.registry.push(RegistryRecord { -// plugin_type, -// data: registry_data.clone(), -// }); - -// let new_size = account -// .data_len() -// .checked_add(size_increase) -// .ok_or(MplAssetError::NumericalOverflow)?; - -// resize_or_reallocate_account_raw(account, payer, system_program, new_size)?; - -// header.save(account, asset.get_size())?; -// plugin.save(account, old_registry_offset)?; -// plugin_registry.save(account, new_registry_offset)?; -// } - -// Ok(()) -// } - /// Add a plugin to the registry and initialize it. pub fn initialize_plugin<'a>( plugin: &Plugin, @@ -309,7 +224,6 @@ pub fn delete_plugin<'a>( let next_plugin_offset = plugin_offset .checked_add(serialized_plugin.len()) .ok_or(MplAssetError::NumericalOverflow)?; - solana_program::msg!("next_plugin_offset: {:?}", next_plugin_offset); let new_size = account .data_len() @@ -317,23 +231,19 @@ pub fn delete_plugin<'a>( .ok_or(MplAssetError::NumericalOverflow)? .checked_sub(serialized_plugin.len()) .ok_or(MplAssetError::NumericalOverflow)?; - solana_program::msg!("new_size: {:?}", new_size); let new_offset = header .plugin_registry_offset .checked_sub(serialized_plugin.len()) .ok_or(MplAssetError::NumericalOverflow)?; - solana_program::msg!("new_offset: {:?}", new_offset); let data_to_move = header .plugin_registry_offset .checked_sub(new_offset) .ok_or(MplAssetError::NumericalOverflow)?; - solana_program::msg!("data_to_move: {:?}", data_to_move); //TODO: This is memory intensive, we should use memmove instead probably. let src = account.data.borrow()[next_plugin_offset..].to_vec(); - solana_program::msg!("src: {:?}", src); sol_memcpy( &mut account.data.borrow_mut()[plugin_offset..], &src, diff --git a/programs/mpl-core/src/processor/burn.rs b/programs/mpl-core/src/processor/burn.rs index 4464c3df..e692ca34 100644 --- a/programs/mpl-core/src/processor/burn.rs +++ b/programs/mpl-core/src/processor/burn.rs @@ -48,11 +48,9 @@ pub(crate) fn burn<'a>(accounts: &'a [AccountInfo<'a>], args: BurnArgs) -> Progr let mut authority_check: Result<(), ProgramError> = Err(MplAssetError::InvalidAuthority.into()); if asset.get_size() != ctx.accounts.asset_address.data_len() { - solana_program::msg!("Fetch Plugin"); let (authorities, plugin, _) = fetch_plugin(ctx.accounts.asset_address, PluginType::Freeze)?; - solana_program::msg!("Assert authority"); authority_check = assert_authority(&asset, ctx.accounts.authority, &authorities); if let Plugin::Freeze(delegate) = plugin { diff --git a/programs/mpl-core/src/processor/transfer.rs b/programs/mpl-core/src/processor/transfer.rs index da21bca7..911c410e 100644 --- a/programs/mpl-core/src/processor/transfer.rs +++ b/programs/mpl-core/src/processor/transfer.rs @@ -96,13 +96,11 @@ pub(crate) fn transfer<'a>(accounts: &'a [AccountInfo<'a>], args: TransferArgs) }; if let Some(plugin_registry) = plugin_registry { - solana_program::msg!("Iterating through plugin registry"); for record in plugin_registry.registry { if matches!( record.plugin_type.check_transfer(), CheckResult::CanApprove | CheckResult::CanReject ) { - solana_program::msg!("Validating Transfer for {:#?}", record.plugin_type); let result = Plugin::load(ctx.accounts.asset_address, record.data.offset)? .validate_transfer(&ctx.accounts, &args, &record.data.authorities)?; if result == ValidationResult::Rejected { diff --git a/programs/mpl-core/src/processor/update.rs b/programs/mpl-core/src/processor/update.rs index 271868d1..8538fba3 100644 --- a/programs/mpl-core/src/processor/update.rs +++ b/programs/mpl-core/src/processor/update.rs @@ -35,7 +35,6 @@ pub(crate) fn update<'a>(accounts: &'a [AccountInfo<'a>], args: UpdateArgs) -> P let (mut asset, plugin_header, plugin_registry) = fetch_core_data(ctx.accounts.asset_address)?; let asset_size = asset.get_size() as isize; - solana_program::msg!("asset_size: {:?}", asset_size); let mut approved = false; match Asset::check_update() { @@ -87,22 +86,15 @@ pub(crate) fn update<'a>(accounts: &'a [AccountInfo<'a>], args: UpdateArgs) -> P (plugin_header, plugin_registry) { let new_asset_size = asset.get_size() as isize; - solana_program::msg!("new_asset_size: {:?}", new_asset_size); let size_diff = new_asset_size .checked_sub(asset_size) .ok_or(MplAssetError::NumericalOverflow)?; let new_size = (ctx.accounts.asset_address.data_len() as isize) .checked_add(size_diff) .ok_or(MplAssetError::NumericalOverflow)?; - solana_program::msg!("size_diff: {:?}", size_diff); - solana_program::msg!( - "old plugin_registry_offset: {:?}", - plugin_header.plugin_registry_offset - ); let new_registry_offset = (plugin_header.plugin_registry_offset as isize) .checked_add(size_diff) .ok_or(MplAssetError::NumericalOverflow)?; - solana_program::msg!("new_registry_offset: {:?}", new_registry_offset); let registry_offset = plugin_header.plugin_registry_offset; plugin_header.plugin_registry_offset = new_registry_offset as usize; diff --git a/programs/mpl-core/src/processor/update_plugin.rs b/programs/mpl-core/src/processor/update_plugin.rs index 7f8864c6..cc96a4c1 100644 --- a/programs/mpl-core/src/processor/update_plugin.rs +++ b/programs/mpl-core/src/processor/update_plugin.rs @@ -29,7 +29,6 @@ pub(crate) fn update_plugin<'a>( } let (asset, _, plugin_registry) = fetch_core_data(ctx.accounts.asset_address)?; - solana_program::msg!("Fetched Core Data"); let plugin_registry = plugin_registry.ok_or(MplAssetError::PluginsNotInitialized)?; let plugin_type: PluginType = (&args.plugin).into();