Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(sequencer): implement basic app side mempool with nonce ordering (…
…#1000) ## Summary implement a basic app side mempool with nonce ordering. the mempool works as follows: - when a tx passes `check_tx`, it's inserted into the mempool. if a tx fails `check_tx` it's removed from the mempool (if it was in it already) - during `prepare_proposal`, txs passed in from cometbft are ignored, and txs are popped from the app's mempool instead. - after a block is finalized, any included txs are removed from the mempool, and the priorities of the txs remaining are updated. - txs in the mempool are ordered by nonce, specifically the differential between the tx nonce and the current account nonce. the lower the differential, the higher the priority. for example, a tx with nonce 7 sent from an account with nonce 7 is a higher priority than a tx with nonce 1 sent from an account with nonce 0. question (maybe for a follow up): there is no reason for a non-validator node to have the app-side mempool, as it doesn't gossip. should we make a config flag to enable/disable it? ## Background - cometbft mempool is too opaque, doesn't know about app-specific ordering, should only be used for tx gossip - will help with the sequencer api (can return pending nonce for an account) - can use for fee-based ordering or tx expiry time in the future ## Changes - implementation of a basic nonce-ordered mempool - update `App` to use this mempool (see summary for how it works) - updated `App` to have separate functions for executing txs in prepare vs process proposal, as the functionality of the two was diverging too much - update the `mempool` service to also use the mempool in `check_tx` ## Testing unit tests ## Related Issues closes #856
- Loading branch information