-
Notifications
You must be signed in to change notification settings - Fork 82
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(sequencer): remove global state (#1317)
## Summary Removed all global from sequencer. ## Background Upon init, sequencer stored its native asset and address base prefix at a fixed global memory locations. This did not yet lead to issues during runtime (because we don't mutate global after startup), it made testing unnecessarily difficult: sequencer relies heavily on unit tests, yet the tests were impure because they relied on the same global state. The changes to the `mempool` module shows another issue: while the mempool could be wholly agnostic to the specific global state, heavy use of the global base prefix meant was less decoupled than it could be. Because sequencer explicitly passes around state (in the form of state deltas, the data inside which are made accessible via various `StateReadExt` and `StateWriteExt` traits), we can read the configured base prefix and native assets from there. The downside is that this patch introduces more database reads. However, given the amounts of data sequencer is dealing with this might not matter and can be alleviated by using a rocksdb Cache (or other mechanism) instead of relying on globals. ## Changes - Remove global setters and writers in `crate::address` and `crate::assets` - Update all code to read the base address prefix and native asset through `crate::address::StateReadExt` and `crate::address::assets::StateReadExt` instead. - Update the mempool to be agnostic of address prefixes and use address bytes insteda: this change is in line with sequencer design considerations in that the address prefix only matters at the boundary while state reads are done via the address bytes underlying the bech32m addresses. - Require that the sequencer genesis contains a `TracePrefixed` asset. ## Testing Updated all tests to either use hard coded prefixes, native assets (if not performing reads or writes on state deltas), or write a base prefix and native asset to state before performing tests (if accessing state). ## Breaking Changelist While the change to `astria-core` is technically breaking (because a field that was of type `asset::Denom` is now `asset::TracePrefixed`), in practice this change is not breaking because Sequencer required native assets to be non-ibc prefixed. ## Related Issues Closes #1208
- Loading branch information
1 parent
8171eed
commit c765408
Showing
37 changed files
with
1,010 additions
and
867 deletions.
There are no files selected for viewing
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
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.