Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sort transactions in the pool by actual fee scaled by the minimum fee #4176

Open
davidyuk opened this issue Aug 2, 2023 · 1 comment
Open
Labels
need/triage New issues which need to be categorized

Comments

@davidyuk
Copy link
Member

davidyuk commented Aug 2, 2023

-spec pool_db_key(aetx_sign:signed_tx()) -> pool_db_key().
pool_db_key(SignedTx) ->
Tx = aetx_sign:tx(SignedTx),
%% INFO: Sort by fee, then by gas price, then by origin, then by nonce
%% INFO: * given that nonce is an index of transactions for a user,
%% the following key is unique for a transaction
%% * negative fee and negative gas price place high profit
%% transactions at the beginning
%% * ordered_set type enables implicit overwrite of the same txs
?KEY(-aetx:deep_fee(Tx), -int_gas_price(Tx),
aetx:origin(Tx), aetx:nonce(Tx), aetx_sign:hash(SignedTx)).

As I understand, transactions in the mempool are ordered according to absolute fee value. The minimum fee for longer transactions (in bytes) or transactions of special types (like ChannelForceProgressTx) is higher. It means that these transactions would be mined firstly, e.g. simple transactions need fees higher than required for complex transactions to overcome them. Which is not obvious.

I propose to order transactions in mempool by the transaction fee divided by the minimum fee for this transaction. This way a slight fee increase would make tx to be mined earlier than all other transactions that use the minimum fee. Also, the sophisticated way to calculate min fee would stay involved after the blockchain load would make users increase fees. Currently, in this case, the current-demand-fee would be the same for transactions regardless of their type and length.

@davidyuk davidyuk added the need/triage New issues which need to be categorized label Aug 2, 2023
@davidyuk
Copy link
Member Author

davidyuk commented Aug 2, 2023

I recalled that fee is a gas * gas price, so we can divide the fee by gas and get a gas price to sort by.
Probably -aetx:deep_fee(Tx), -int_gas_price(Tx) can be replaced with just -<gas price>.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
need/triage New issues which need to be categorized
Projects
None yet
Development

No branches or pull requests

1 participant