Skip to content
This repository was archived by the owner on Jan 22, 2025. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2,274 changes: 1,198 additions & 1,076 deletions Cargo.lock

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ members = [
"programs/stake",
"programs/vote",
"programs/zk-token-proof",
"programs/application-fees",
"programs/application-fees-tests",
"pubsub-client",
"quic-client",
"rayon-threadlimit",
Expand Down
15 changes: 12 additions & 3 deletions account-decoder/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ use {
crate::parse_account_data::{parse_account_data, AccountAdditionalData, ParsedAccount},
solana_sdk::{
account::{ReadableAccount, WritableAccount},
clock::Epoch,
fee_calculator::FeeCalculator,
pubkey::Pubkey,
},
Expand All @@ -42,8 +41,9 @@ pub struct UiAccount {
pub data: UiAccountData,
pub owner: String,
pub executable: bool,
pub rent_epoch: Epoch,
pub rent_epoch: u64,
pub space: Option<u64>,
pub application_fees: Option<u64>,
}

#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
Expand Down Expand Up @@ -131,6 +131,11 @@ impl UiAccount {
executable: account.executable(),
rent_epoch: account.rent_epoch(),
space: Some(space as u64),
application_fees: if account.has_application_fees() {
Some(account.application_fees())
} else {
None
},
}
}

Expand All @@ -151,12 +156,16 @@ impl UiAccount {
UiAccountEncoding::Binary | UiAccountEncoding::JsonParsed => None,
},
}?;
let has_app_fees: bool = self.application_fees.is_some();
Some(T::create(
self.lamports,
data,
Pubkey::from_str(&self.owner).ok()?,
self.executable,
self.rent_epoch,
if has_app_fees { 0 } else { self.rent_epoch },
// TODO APPLICATION_FEES
has_app_fees,
self.application_fees.map_or(0, |x| x),
))
}
}
Expand Down
10 changes: 6 additions & 4 deletions banks-server/src/banks_server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -356,10 +356,12 @@ impl Banks for BanksServer {
) -> BanksTransactionResultWithMetadata {
let bank = self.bank_forks.read().unwrap().working_bank();
match bank.process_transaction_with_metadata(transaction) {
TransactionExecutionResult::NotExecuted(error) => BanksTransactionResultWithMetadata {
result: Err(error),
metadata: None,
},
TransactionExecutionResult::NotExecuted { error, .. } => {
BanksTransactionResultWithMetadata {
result: Err(error),
metadata: None,
}
}
TransactionExecutionResult::Executed { details, .. } => {
BanksTransactionResultWithMetadata {
result: details.status,
Expand Down
3 changes: 2 additions & 1 deletion bench-tps/tests/bench_tps.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ fn program_account(program_data: &[u8]) -> AccountSharedData {
data: program_data.to_vec(),
owner: solana_sdk::bpf_loader::id(),
executable: true,
rent_epoch: 0,
has_application_fees: false,
rent_epoch_or_application_fees: 0,
})
}

Expand Down
5 changes: 4 additions & 1 deletion cli-output/src/cli_output.rs
Original file line number Diff line number Diff line change
Expand Up @@ -192,9 +192,12 @@ impl fmt::Display for CliAccount {
)?;
writeln_name_value(
f,
"Rent Epoch:",
"Rent Epoch",
&self.keyed_account.account.rent_epoch.to_string(),
)?;
if let Some(application_fees) = self.keyed_account.account.application_fees {
writeln_name_value(f, "Application Fees", &application_fees.to_string())?;
}
Ok(())
}
}
Expand Down
1 change: 1 addition & 0 deletions core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ rolling-file = "0.2.0"
serde = "1.0.152"
serde_derive = "1.0.103"
solana-address-lookup-table-program = { path = "../programs/address-lookup-table", version = "=1.16.0" }
solana-application-fees-program = { path = "../programs/application-fees", version = "=1.16.0" }
solana-bloom = { path = "../bloom", version = "=1.16.0" }
solana-client = { path = "../client", version = "=1.16.0" }
solana-entry = { path = "../entry", version = "=1.16.0" }
Expand Down
9 changes: 6 additions & 3 deletions genesis/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -629,7 +629,8 @@ fn main() -> Result<(), Box<dyn error::Error>> {
data: program_data,
executable: true,
owner: loader,
rent_epoch: 0,
has_application_fees: false,
rent_epoch_or_application_fees: 0,
}),
);
}
Expand Down Expand Up @@ -673,7 +674,8 @@ fn main() -> Result<(), Box<dyn error::Error>> {
data: program_data,
owner: loader,
executable: false,
rent_epoch: 0,
has_application_fees: false,
rent_epoch_or_application_fees: 0,
}),
);

Expand All @@ -688,7 +690,8 @@ fn main() -> Result<(), Box<dyn error::Error>> {
data: program_data,
owner: loader,
executable: true,
rent_epoch: 0,
has_application_fees: false,
rent_epoch_or_application_fees: 0,
}),
);
}
Expand Down
12 changes: 9 additions & 3 deletions geyser-plugin-manager/src/accounts_update_notifier.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use {
append_vec::StoredAccountMeta,
},
solana_sdk::{
account::{AccountSharedData, ReadableAccount},
account::{AccountSharedData, ReadableAccount, RENT_EXEMPT_RENT_EPOCH},
clock::Slot,
pubkey::Pubkey,
signature::Signature,
Expand Down Expand Up @@ -131,8 +131,14 @@ impl AccountsUpdateNotifierImpl {
pubkey: stored_account_meta.pubkey().as_ref(),
lamports: stored_account_meta.account_meta.lamports,
owner: stored_account_meta.account_meta.owner.as_ref(),
executable: stored_account_meta.account_meta.executable,
rent_epoch: stored_account_meta.account_meta.rent_epoch,
executable: stored_account_meta.account_meta.executable(),
rent_epoch: if stored_account_meta.account_meta.has_application_fees() {
RENT_EXEMPT_RENT_EPOCH
} else {
stored_account_meta
.account_meta
.rent_epoch_or_application_fees
},
data: stored_account_meta.data,
write_version: stored_account_meta.meta.write_version_obsolete,
txn_signature: None,
Expand Down
2 changes: 2 additions & 0 deletions ledger-tool/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -390,6 +390,8 @@ fn output_account(
}
println!(" rent_epoch: {}", account.rent_epoch());
println!(" data_len: {}", account.data().len());
println!(" has_application_fees: {}", account.has_application_fees());
println!(" application_fees: {}", account.application_fees());
if print_account_data {
let account_data = UiAccount::encode(pubkey, account, encoding, None, None).data;
match account_data {
Expand Down
2 changes: 1 addition & 1 deletion ledger/src/blockstore_processor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1675,7 +1675,7 @@ impl TransactionStatusSender {
.into_iter()
.map(|result| match result {
TransactionExecutionResult::Executed { details, .. } => Some(details),
TransactionExecutionResult::NotExecuted(_) => None,
TransactionExecutionResult::NotExecuted { .. } => None,
})
.collect(),
balances,
Expand Down
30 changes: 20 additions & 10 deletions ledger/src/token_balances.rs
Original file line number Diff line number Diff line change
Expand Up @@ -156,15 +156,17 @@ mod test {
data: data.to_vec(),
owner: pubkey_from_spl_token(&spl_token::id()),
executable: false,
rent_epoch: 0,
has_application_fees: false,
rent_epoch_or_application_fees: 0,
};
let other_mint_pubkey = Pubkey::new_unique();
let other_mint = Account {
lamports: 100,
data: data.to_vec(),
owner: Pubkey::new_unique(), // !is_known_spl_token_id
executable: false,
rent_epoch: 0,
has_application_fees: false,
rent_epoch_or_application_fees: 0,
};

let token_owner = Pubkey::new_unique();
Expand All @@ -186,14 +188,16 @@ mod test {
data: data.to_vec(),
owner: pubkey_from_spl_token(&spl_token::id()),
executable: false,
rent_epoch: 0,
has_application_fees: false,
rent_epoch_or_application_fees: 0,
};
let other_account = Account {
lamports: 100,
data: data.to_vec(),
owner: Pubkey::new_unique(), // !is_known_spl_token_id
executable: false,
rent_epoch: 0,
has_application_fees: false,
rent_epoch_or_application_fees: 0,
};

let other_mint_data = TokenAccount {
Expand All @@ -214,7 +218,8 @@ mod test {
data: data.to_vec(),
owner: pubkey_from_spl_token(&spl_token::id()),
executable: false,
rent_epoch: 0,
has_application_fees: false,
rent_epoch_or_application_fees: 0,
};

let mut accounts = BTreeMap::new();
Expand Down Expand Up @@ -319,15 +324,17 @@ mod test {
data: mint_data.to_vec(),
owner: pubkey_from_spl_token(&spl_token_2022::id()),
executable: false,
rent_epoch: 0,
has_application_fees: false,
rent_epoch_or_application_fees: 0,
};
let other_mint_pubkey = Pubkey::new_unique();
let other_mint = Account {
lamports: 100,
data: mint_data.to_vec(),
owner: Pubkey::new_unique(),
executable: false,
rent_epoch: 0,
has_application_fees: false,
rent_epoch_or_application_fees: 0,
};

let token_owner = Pubkey::new_unique();
Expand Down Expand Up @@ -363,14 +370,16 @@ mod test {
data: account_data.to_vec(),
owner: pubkey_from_spl_token(&spl_token_2022::id()),
executable: false,
rent_epoch: 0,
has_application_fees: false,
rent_epoch_or_application_fees: 0,
};
let other_account = Account {
lamports: 100,
data: account_data.to_vec(),
owner: Pubkey::new_unique(),
executable: false,
rent_epoch: 0,
has_application_fees: false,
rent_epoch_or_application_fees: 0,
};

let other_mint_token_base = TokenAccount {
Expand Down Expand Up @@ -405,7 +414,8 @@ mod test {
data: account_data.to_vec(),
owner: pubkey_from_spl_token(&spl_token_2022::id()),
executable: false,
rent_epoch: 0,
has_application_fees: false,
rent_epoch_or_application_fees: 0,
};

let mut accounts = BTreeMap::new();
Expand Down
36 changes: 35 additions & 1 deletion program-runtime/src/invoke_context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ use {
alloc::Layout,
borrow::Cow,
cell::RefCell,
collections::HashMap,
fmt::{self, Debug},
rc::Rc,
sync::Arc,
Expand Down Expand Up @@ -101,6 +102,13 @@ struct SyscallContext {
allocator: Rc<RefCell<dyn Alloc>>,
}

#[derive(Clone, PartialEq, Eq, Debug, Default)]
pub struct ApplicationFeeChanges {
pub application_fees: HashMap<Pubkey, u64>,
pub rebated: HashMap<Pubkey, u64>,
pub updated: Vec<(Pubkey, u64)>,
}

pub struct InvokeContext<'a> {
pub transaction_context: &'a mut TransactionContext,
rent: Rent,
Expand All @@ -119,6 +127,7 @@ pub struct InvokeContext<'a> {
pub blockhash: Hash,
pub lamports_per_signature: u64,
syscall_context: Vec<Option<SyscallContext>>,
pub application_fee_changes: ApplicationFeeChanges,
}

impl<'a> InvokeContext<'a> {
Expand All @@ -135,6 +144,7 @@ impl<'a> InvokeContext<'a> {
blockhash: Hash,
lamports_per_signature: u64,
prev_accounts_data_len: u64,
application_fees: HashMap<Pubkey, u64>,
) -> Self {
Self {
transaction_context,
Expand All @@ -154,6 +164,11 @@ impl<'a> InvokeContext<'a> {
blockhash,
lamports_per_signature,
syscall_context: Vec::new(),
application_fee_changes: ApplicationFeeChanges {
application_fees,
rebated: HashMap::new(),
updated: Vec::new(),
},
}
}

Expand Down Expand Up @@ -191,6 +206,7 @@ impl<'a> InvokeContext<'a> {
Hash::default(),
0,
0,
HashMap::new(),
)
}

Expand Down Expand Up @@ -369,6 +385,24 @@ impl<'a> InvokeContext<'a> {
.checked_add(u128::from(account.lamports()))
.ok_or(InstructionError::UnbalancedInstruction)?;

// additional check on application fees if they are balanced / ie if account has application fees then they should be either in application fees or in rebates
if pre_account.has_application_fees() {
let key = pre_account.key();
let app_fees = self
.application_fee_changes
.application_fees
.get(key)
.map_or(0, |x| *x);
let rebates = self
.application_fee_changes
.rebated
.get(key)
.map_or(0, |x| *x);
if pre_account.application_fees() != app_fees + rebates {
return Err(InstructionError::UnbalancedInstruction);
}
}

let pre_data_len = pre_account.data().len() as i64;
let post_data_len = account.data().len() as i64;
let data_len_delta = post_data_len.saturating_sub(pre_data_len);
Expand Down Expand Up @@ -454,7 +488,7 @@ impl<'a> InvokeContext<'a> {
.checked_add(u128::from(account.lamports()))
.ok_or(InstructionError::UnbalancedInstruction)?;
if is_writable && !pre_account.executable() {
pre_account.update(account.clone());
pre_account.update(account.clone())?;
}

let pre_data_len = pre_account.data().len() as i64;
Expand Down
Loading