Skip to content

Commit

Permalink
prioritization multiplier
Browse files Browse the repository at this point in the history
  • Loading branch information
apfitzge committed Jan 24, 2024
1 parent f8fb19a commit 71899b7
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -775,7 +775,7 @@ mod tests {
&Keypair::new(),
&Pubkey::new_unique(),
1,
1,
10,
bank.last_blockhash(),
);
let tx2 = create_and_fund_prioritized_transfer(
Expand All @@ -784,7 +784,7 @@ mod tests {
&Keypair::new(),
&Pubkey::new_unique(),
1,
2,
20,
bank.last_blockhash(),
);
let tx1_hash = tx1.message().hash();
Expand Down Expand Up @@ -831,7 +831,7 @@ mod tests {
&Keypair::new(),
&pk,
1,
1,
10,
bank.last_blockhash(),
);
let tx2 = create_and_fund_prioritized_transfer(
Expand All @@ -840,7 +840,7 @@ mod tests {
&Keypair::new(),
&pk,
1,
2,
20,
bank.last_blockhash(),
);
let tx1_hash = tx1.message().hash();
Expand Down Expand Up @@ -892,7 +892,7 @@ mod tests {
&Keypair::new(),
&Pubkey::new_unique(),
i as u64,
1,
10,
bank.last_blockhash(),
)
})
Expand All @@ -905,7 +905,7 @@ mod tests {
&Keypair::new(),
&Pubkey::new_unique(),
i as u64,
2,
20,
bank.last_blockhash(),
)
})
Expand Down Expand Up @@ -956,7 +956,7 @@ mod tests {
&Keypair::new(),
&Pubkey::new_unique(),
1,
i,
i * 10,
bank.last_blockhash(),
)
})
Expand Down Expand Up @@ -1022,7 +1022,7 @@ mod tests {
&Keypair::new(),
&Pubkey::new_unique(),
1,
1,
10,
bank.last_blockhash(),
);
let tx2 = create_and_fund_prioritized_transfer(
Expand All @@ -1031,7 +1031,7 @@ mod tests {
&Keypair::new(),
&Pubkey::new_unique(),
1,
2,
20,
bank.last_blockhash(),
);
let tx1_hash = tx1.message().hash();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,8 +166,13 @@ impl TransactionStateContainer {
lamports_per_signature * state.transaction_ttl().transaction.signatures().len() as u64;
let cost = state.transaction_cost().sum();

signature_fees
.saturating_add(priority_fee)
// We need a multiplier here to avoid rounding down too aggressively.
// For many small transactions, the cost will be greater than the fees in terms of raw lamports.
// For the purposes of calculating prioritization, we multiply the fees by a large number so that
// the cost is a small fraction.
const MULTIPLIER: u64 = 1_000_000;
(signature_fees.saturating_add(priority_fee))
.saturating_mul(MULTIPLIER)
.saturating_div(cost)
}
}
Expand Down

0 comments on commit 71899b7

Please sign in to comment.