Skip to content

Commit

Permalink
Revert "Adding scaling fees based on native SVM rent (#139)" (#151)
Browse files Browse the repository at this point in the history
* Revert "Adding scaling fees based on native SVM rent (#139)"

This reverts commit 65c3a71.

* Had to fix merge conflicts mostly around imports.

* Also left the CI upload fix included.

* Run CI on new branch
  • Loading branch information
danenbm committed Nov 1, 2024
1 parent 2878f77 commit 76ea371
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 27 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ name: Main

on:
push:
branches: [main]
branches: [main, fixed-fee]
pull_request:
branches: [main]
branches: [main, fixed-fee]

env:
CACHE: true
Expand Down
11 changes: 1 addition & 10 deletions programs/token-metadata/program/src/state/fee.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use super::*;
use solana_program::{rent::Rent, sysvar::Sysvar};

pub(crate) const FEE_AUTHORITY: Pubkey = pubkey!("Levytx9LLPzAtDJJD7q813Zsm8zg9e1pb53mGxTKpD7");
pub const FEE_DESTINATION: Pubkey = pubkey!("2fb1TjRrJQLy9BkYfBjcYgibV7LUsr9cf6QxvyRZyuXn");
Expand All @@ -11,16 +10,8 @@ pub(crate) const RESIZE_AUTHORITY: Pubkey = pubkey!("ResizebfwTEZTLbHbctTByvXYEC
pub(crate) const RESIZE_DESTINATION: Pubkey =
pubkey!("46mjNQBwXLCDCM7YiDQSPVdNZ4dLdZf79tTPRkT1wkF6");

const CREATE_FEE_SCALAR: usize = 1308;
const CREATE_FEE_OFFSET: u64 = 5440;
// create_metadata_accounts_v3, create, print edition commands
pub fn get_create_fee() -> Result<u64, ProgramError> {
let rent = Rent::get()?.minimum_balance(CREATE_FEE_SCALAR);

Ok(rent
.checked_add(CREATE_FEE_OFFSET)
.ok_or(MetadataError::NumericalOverflowError)?)
}
pub const CREATE_FEE: u64 = 10_000_000;

pub const FEE_FLAG_SET: u8 = 1;
pub const FEE_FLAG_CLEARED: u8 = 0;
4 changes: 2 additions & 2 deletions programs/token-metadata/program/src/utils/fee.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use solana_program::{

use crate::{
error::MetadataError,
state::{get_create_fee, MAX_METADATA_LEN, METADATA_FEE_FLAG_OFFSET},
state::{fee::CREATE_FEE, MAX_METADATA_LEN, METADATA_FEE_FLAG_OFFSET},
};

#[repr(C)]
Expand All @@ -26,7 +26,7 @@ pub(crate) fn levy(args: LevyArgs) -> ProgramResult {
if account_data_len > 0 {
return Err(MetadataError::ExpectedUninitializedAccount.into());
}
let fee = get_create_fee()? + rent.minimum_balance(MAX_METADATA_LEN);
let fee = CREATE_FEE + rent.minimum_balance(MAX_METADATA_LEN);

invoke(
&solana_program::system_instruction::transfer(
Expand Down
6 changes: 3 additions & 3 deletions programs/token-metadata/program/tests/fees.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ mod fees {
error::MetadataError,
instruction::{collect_fees, BurnArgs, UpdateArgs},
state::{
FEE_DESTINATION, FEE_FLAG_CLEARED, FEE_FLAG_SET, METADATA_FEE_FLAG_OFFSET,
CREATE_FEE, FEE_DESTINATION, FEE_FLAG_CLEARED, FEE_FLAG_SET, METADATA_FEE_FLAG_OFFSET,
OWNERLESS_CLOSE_DESTINATION,
},
};
Expand Down Expand Up @@ -155,7 +155,7 @@ mod fees {
println!("Transaction size: {:?}", tx.message().serialize().len());
context.banks_client.process_transaction(tx).await.unwrap();

let expected_balance = num_accounts * SOLANA_CREATE_FEE;
let expected_balance = num_accounts * CREATE_FEE;

let recipient_balance = get_account(&mut context, &FEE_DESTINATION).await.lamports;

Expand Down Expand Up @@ -226,7 +226,7 @@ mod fees {
);
context.banks_client.process_transaction(tx).await.unwrap();

let expected_balance = SOLANA_CREATE_FEE;
let expected_balance = CREATE_FEE;

let recipient_balance = get_account(&mut context, &FEE_DESTINATION).await.lamports;

Expand Down
11 changes: 5 additions & 6 deletions programs/token-metadata/program/tests/utils/digital_asset.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,16 @@ use token_metadata::{
state::{
AssetData, Collection, CollectionDetails, Creator, MasterEditionV2, Metadata, PrintSupply,
ProgrammableConfig, TokenDelegateRole, TokenMetadataAccount, TokenRecord, TokenStandard,
EDITION, EDITION_MARKER_BIT_SIZE, FEE_FLAG_SET, METADATA_FEE_FLAG_OFFSET, PREFIX,
CREATE_FEE, EDITION, EDITION_MARKER_BIT_SIZE, FEE_FLAG_SET, METADATA_FEE_FLAG_OFFSET,
PREFIX,
},
utils::unpack,
ID,
};

use crate::{upsize_edition, SOLANA_CREATE_FEE};

use super::{
airdrop, create_mint, create_token_account, get_account, mint_tokens, upsize_master_edition,
upsize_metadata,
airdrop, create_mint, create_token_account, get_account, mint_tokens, upsize_edition,
upsize_master_edition, upsize_metadata,
};

pub const DEFAULT_NAME: &str = "Digital Asset";
Expand Down Expand Up @@ -1493,7 +1492,7 @@ impl DigitalAsset {
let rent = context.banks_client.get_rent().await.unwrap();
let rent_exempt = rent.minimum_balance(account.data.len());

let expected_lamports = rent_exempt + SOLANA_CREATE_FEE;
let expected_lamports = rent_exempt + CREATE_FEE;

assert_eq!(account.lamports, expected_lamports);
let last_byte = account.data.len() - METADATA_FEE_FLAG_OFFSET;
Expand Down
5 changes: 3 additions & 2 deletions programs/token-metadata/program/tests/utils/metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ use token_metadata::{
pda::find_master_edition_account,
state::{
Collection, CollectionDetails, Creator, DataV2, Metadata as TmMetadata,
TokenMetadataAccount, TokenStandard, Uses, FEE_FLAG_SET, METADATA_FEE_FLAG_OFFSET, PREFIX,
TokenMetadataAccount, TokenStandard, Uses, CREATE_FEE, FEE_FLAG_SET,
METADATA_FEE_FLAG_OFFSET, PREFIX,
},
ID,
};
Expand Down Expand Up @@ -768,7 +769,7 @@ impl Metadata {
let rent = context.banks_client.get_rent().await.unwrap();
let rent_exempt = rent.minimum_balance(account.data.len());

let expected_lamports = rent_exempt + SOLANA_CREATE_FEE;
let expected_lamports = rent_exempt + CREATE_FEE;

assert_eq!(account.lamports, expected_lamports);
let last_byte = account.data.len() - METADATA_FEE_FLAG_OFFSET;
Expand Down
2 changes: 0 additions & 2 deletions programs/token-metadata/program/tests/utils/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@ pub const DEFAULT_COLLECTION_DETAILS: Option<CollectionDetails> = {
Some(CollectionDetails::V1 { size: 0 })
};

pub const SOLANA_CREATE_FEE: u64 = 10_000_000;

pub fn program_test() -> ProgramTest {
let mut program_test = ProgramTest::new("token_metadata", token_metadata::ID, None);
program_test.add_program("spl_token_2022", spl_token_2022::ID, None);
Expand Down

0 comments on commit 76ea371

Please sign in to comment.