Skip to content

Commit

Permalink
Removing debug prints.
Browse files Browse the repository at this point in the history
  • Loading branch information
blockiosaurus committed Feb 26, 2024
1 parent 5f45abf commit 1d20c0e
Show file tree
Hide file tree
Showing 6 changed files with 0 additions and 106 deletions.
3 changes: 0 additions & 3 deletions programs/mpl-core/src/plugins/transfer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,14 +77,11 @@ impl PluginValidation for Transfer {
_args: &TransferArgs,
authorities: &[Authority],
) -> Result<super::ValidationResult, solana_program::program_error::ProgramError> {
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)
}
}
Expand Down
90 changes: 0 additions & 90 deletions programs/mpl-core/src/plugins/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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))
}
Expand Down Expand Up @@ -125,87 +121,6 @@ pub fn list_plugins(account: &AccountInfo) -> Result<Vec<PluginType>, 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,
Expand Down Expand Up @@ -309,31 +224,26 @@ 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()
.checked_sub(serialized_registry_record.len())
.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,
Expand Down
2 changes: 0 additions & 2 deletions programs/mpl-core/src/processor/burn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 0 additions & 2 deletions programs/mpl-core/src/processor/transfer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
8 changes: 0 additions & 8 deletions programs/mpl-core/src/processor/update.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -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;

Expand Down
1 change: 0 additions & 1 deletion programs/mpl-core/src/processor/update_plugin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit 1d20c0e

Please sign in to comment.