-
Notifications
You must be signed in to change notification settings - Fork 88
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(sequencer)!: fix TOCTOU issues by merging check and execution (#1332
) ## Summary Introduces `ActionHandler::check_and_execute`, replacing `ActionHandler::check_stateful` and `ActionHandler::execute`. ## Background Zelic found that separating execution into `check_stateful` and `execute` lead to time-of-check-vs-time-of-use risks: while `check_stateful` for two actions `A` and `B` might each pass, the execution of action `A` might change the state such that a subsequent execution of action `B` would now fail - or worse, lead to invalid state. This patch follows Penumbra (see issues linked at the bottom) in merging them into one atomic operation (atomic in the sense that `<Action>::check_and_execute` are run sequentially). There is also a `ActionHandler::check_historic` trait method, which however is currently not used. It is left for future work to go through the individual checks and move them to `check_historic`, where applicable (for example, checking address prefixes as long as changing these is not possible after chain init). ## Changes - change `ActionHandler` trait to merge `check_stateful` and `execute` into `check_and_execute`. - inject a transaction's signer into the ephemeral object store, setting before and after a transaction is executed. Necessary because this follows the `cnidarium_component::ActionHandler` convention, but also allows simplifying - remove the notion of bech32m addresses from many state writes and reads: the prefix only matters at the boundary, not inside the system ## Testing All tests were updated and pass. NOTE: a useful test would be to craft a problematic transaction that would be rejected with the newest change. However, crafting and executing such a transaction so that it is rejected by the current sequencer but leads to incorrect is left to a follow-up. ## Breaking Changelist While no snapshots guarding against breaking app state were triggered, this is still a breaking change: if supplied with a problematic payload, a sequencer node without this patch will reach a different (and invalid) state compared a node with the present patch. ## Related Issues Original Penumbra issues and fix: penumbra-zone/penumbra#3960 penumbra-zone/penumbra#3960 Closes #1318 --------- Co-authored-by: Fraser Hutchison <[email protected]>
- Loading branch information
1 parent
7b36af7
commit 9f959f4
Showing
32 changed files
with
992 additions
and
1,291 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.