Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Rework Transaction Priority Calculation #9317

Closed
apopiak opened this issue Jul 9, 2021 · 0 comments · Fixed by #9834
Closed

Rework Transaction Priority Calculation #9317

apopiak opened this issue Jul 9, 2021 · 0 comments · Fixed by #9834
Assignees
Labels
I7-refactor Code needs refactoring.

Comments

@apopiak
Copy link
Contributor

apopiak commented Jul 9, 2021

fn get_priority(len: usize, info: &DispatchInfoOf<T::Call>, final_fee: BalanceOf<T>) -> TransactionPriority {
let weight_saturation = T::BlockWeights::get().max_block / info.weight.max(1);
let max_block_length = *T::BlockLength::get().max.get(DispatchClass::Normal);
let len_saturation = max_block_length as u64 / (len as u64).max(1);
let coefficient: BalanceOf<T> = weight_saturation.min(len_saturation).saturated_into::<BalanceOf<T>>();
final_fee.saturating_mul(coefficient).saturated_into::<TransactionPriority>()
}

Tomek's Comments about Transaction Priority

Why is [the priority] always Normal? Maybe we should get a total length instead? With current implementation we might have large non-normal transactions getting their priority heavily reduced compared to normal transactions.

I think this should be at least 1. For larger-than-block transactions (Mandatory) the coefficient might end up being 0.

I'm not sure if having linear relation here is good. For super small transactions (both len and weight) the priority increase seems to be extremely high (absolute values of min(block_length, block_weight). Given that the only way to counter that is with a tip, I feel it might not be tuned well (like there is no relation between extra tip cost to frontrun such transaction and absolute value of block_weight/block_length).

This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
I7-refactor Code needs refactoring.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants