-
Notifications
You must be signed in to change notification settings - Fork 374
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
[tm2] Improved Mempool Logic #1830
Comments
in this case, the first transaction would be processed priorly because it has a lower account sequence, even it costs less gas? is this reasonable?
|
Yes, transactions should be ordered by 2 sort params:
|
Is this what's done on cometbft / ethereum? |
Yes. This is how most mempool implementations work |
After researching the issue, we determined:
That's why I'm moving it to the post-launch milestone. |
To give clarity, we can't fix these issues without changing the canonical We're leaving it to be an optimization and effort after the mainnet launch |
Description
This effort covers expanding the capabilities of the Mempool module to be more in line with how stable blockchains should work.
The major problems currently present in the Mempool implementation of Gno are:
Transactions are unordered by account sequence
The current implementation of the mempool module does not take into account the account sequence ordering when returning “ready” transactions for block building.
The mempool currently returns transactions only ordered by their gas, and not by account sequence first, and gas second.
This leads to a scenario where the mempool can return transactions for block building that are not in the correct order of sending for an account. For example:
Realm deploys cost more gas, so TX2 will be executed before TX1, since the mempool returns this transaction first (orders by gas). TX 2 will fail, because the account is uninitialized. Account balance transfers cost less gas, so they will be executed first in the mempool implementation.
Block building does not take into account actual gas used by a TX
The current implementation of the block building process does not take into account the actual gas used by a transaction when trying to figure out if it can fit into a block. Instead, the block building process simply reads the (user defined) gas limit, and sees if the block gas enough space to fit the transaction, even though the transaction actually uses less gas than what was specified.
The optimal flow for the block building process would be:
This way, the mempool always has ready transactions that are executable, given the previous point about transaction ordering.
If this is not patched, there is a DDoS vector where a user can spam valid high gas limit transactions and take up all the block space (ex. with a single transaction), leaving no room for the transactions of other users.
Successful outcome of this effort:
The text was updated successfully, but these errors were encountered: