sequencer, mempool: make transaction execution and CheckTx share code #1775
Labels
code-quality
mempool
refactor
code refactoring or maintainence
sequencer
pertaining to the astria-sequencer crate
We want the mempool's CheckTx and the app's transaction execution logic to mostly perform the same checks. Right now the mempool duplicates a lot of the checks that execution performs, which can lead to issues if devs forget to update the CheckTx code when changing the execution code. Instead of trying to remember to update code in a certain way, we should have the code be shared between the two locations.
For example, CheckTx relies on the function
get_total_transaction_cost()
, which has a manual rewrite of fee logic that is trying to duplicate code incheck_and_execute()
which does the action's non-fee balance reductions inside of the action execution. This getting out of sync could cause issues in the mempool's pending vs parked distinction. (Note: thecheck_and_execute()
code also calls into the manual function which is a redundant check that should be removed).This logic was initially separated due to the performance concerns of running the full transaction execution in CheckTx. Since then, we've changed the mempool to only run CheckTx on the first time a transaction is seen instead of on every block. For performance, it would be nice if we could have the CheckTx implementation run the actions checks in parallel.
Other implementation notes:
┆Issue Number: ENG-976
The text was updated successfully, but these errors were encountered: