Skip to content

Commit

Permalink
transaction cost based on requested write-locks
Browse files Browse the repository at this point in the history
  • Loading branch information
apfitzge committed Jan 18, 2024
1 parent d79d7a0 commit fae78b2
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 1 addition & 1 deletion cost-model/src/cost_model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ impl CostModel {
fn get_write_lock_cost(tx_cost: &mut UsageCostDetails, transaction: &SanitizedTransaction) {
tx_cost.writable_accounts = Self::get_writable_accounts(transaction);
tx_cost.write_lock_cost =
WRITE_LOCK_UNITS.saturating_mul(tx_cost.writable_accounts.len() as u64);
WRITE_LOCK_UNITS.saturating_mul(transaction.message().num_write_locks());
}

fn get_transaction_cost(
Expand Down
2 changes: 2 additions & 0 deletions sdk/program/src/message/sanitized.rs
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,8 @@ impl SanitizedMessage {
num_signatures
}

/// Returns the number of requested write-locks in this message.
/// This does not consider if write-locks are demoted.
pub fn num_write_locks(&self) -> u64 {
self.account_keys()
.len()
Expand Down

0 comments on commit fae78b2

Please sign in to comment.