-
Notifications
You must be signed in to change notification settings - Fork 5k
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
[EPIC] Unflatten metamask
Redux slice
#29600
Open
7 of 27 tasks
Labels
contributor experience
An issue that impacts, or planned improvement to, the contributor experience.
epic
release-12.11.0
Issue or pull request that will be included in release 12.11.0
team-extension-platform
team-tiger
Tiger team (for tech debt reduction + performance improvements)
type-tech-debt
Technical debt
Comments
MajorLift
added
contributor experience
An issue that impacts, or planned improvement to, the contributor experience.
team-extension-platform
team-tiger
Tiger team (for tech debt reduction + performance improvements)
type-tech-debt
Technical debt
labels
Jan 9, 2025
MajorLift
changed the title
[EPIC] Unflatten
EPIC: Unflatten Jan 9, 2025
metamask
Redux slicemetamask
Redux slice
This was referenced Jan 9, 2025
gauthierpetetin
changed the title
EPIC: Unflatten
[EPIC] Unflatten Jan 10, 2025
metamask
Redux slicemetamask
Redux slice
github-merge-queue bot
pushed a commit
that referenced
this issue
Jan 13, 2025
…ate` slice (#28703) ## **Description** 1. Moves properties in the `metamask` Redux slice that are not part of background (i.e. controller-derived) state into the `appState` slice. The affected state properties are as follows: ``` customNonceValue: string; isAccountMenuOpen: boolean; isNetworkMenuOpen: boolean; nextNonce: string | null; pendingTokens: { [address: string]: Token & { isCustom?: boolean; unlisted?: boolean }; }; welcomeScreenSeen: boolean; confirmationExchangeRates: ContractExchangeRates; ``` - Foreground properties that are a part of `AppStateController` state have not been moved into the `appState` slice, and will remain in the unflattened `metamask` slice. - It's not immediately clear why the properties listed above were excluded from `AppStateController` state, but since all of them appear to neither require persistence beyond a given session, nor anonymization of PII, I'm opting to maintain the status quo and keep them out of controller state. - The `isInitialized` property is not included, because it's derived from background state before the Redux store is instantiated, and is updated by the `PatchStore` which supplies it directly to the `metamask` slice. 2. Groups `appState` slice selectors in `ui/selectors/selectors.js` together. [![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/MetaMask/metamask-extension/pull/28703?quickstart=1) ## **Related issues** - Closes #29601 - Closes MetaMask/MetaMask-planning#2895 - 0 of 7 PRs that will close #29600 - Blocking MetaMask/MetaMask-planning#2894 - #28723 - #28929 - #28776 ## **Manual testing steps** ## **Screenshots/Recordings** <!-- If applicable, add screenshots and/or recordings to visualize the before and after of your change. --> ### **Before** <!-- [screenshots/recordings] --> ### **After** <!-- [screenshots/recordings] --> ## **Pre-merge author checklist** - [x] I've followed [MetaMask Contributor Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Extension Coding Standards](https://github.com/MetaMask/metamask-extension/blob/develop/.github/guidelines/CODING_GUIDELINES.md). - [x] I've completed the PR template to the best of my ability - [x] I’ve included tests if applicable - [x] I’ve documented my code using [JSDoc](https://jsdoc.app/) format if applicable - [x] I’ve applied the right labels on the PR (see [labeling guidelines](https://github.com/MetaMask/metamask-extension/blob/develop/.github/guidelines/LABELING_GUIDELINES.md)). Not required for external contributors. ## **Pre-merge reviewer checklist** - [ ] I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed). - [ ] I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots.
metamaskbot
added
the
release-12.11.0
Issue or pull request that will be included in release 12.11.0
label
Jan 13, 2025
7 tasks
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
contributor experience
An issue that impacts, or planned improvement to, the contributor experience.
epic
release-12.11.0
Issue or pull request that will be included in release 12.11.0
team-extension-platform
team-tiger
Tiger team (for tech debt reduction + performance improvements)
type-tech-debt
Technical debt
What is this about?
Primary Outcome
In the Extension, our background state object gets “flattened” before being sent to the UI, which obscures the origin of each piece of state and negatively impacts performance (incl. the “UI startup” span). We should stop doing this and instead leave our state grouped by controller.
There are also non-performance benefits:
Phases
1. Preparation
metamask
slice. #29601metamask
slice to TypeScript #29628metamask
slice as temporary measure.metamask
slice with default values for all nested properties. #296292. Horizontal sharding
Repeat the following steps for each controller (group by domain i.e. codeowner team).
Unflattening #4: [[ControllerName]] #1
] Unflattenmetamask
sliceUnflattening #4: [[ControllerName]] #2
] Unflatten selectorsUnflattening #4: [[ControllerName]] #3
] Unflatten hooks, componentsUnflattening #4: [[ControllerName]] #4
] Unflatten mock objectsUnflattening #4: [[ControllerName]] #5
] Unflatten testsUnflattening #4: [[ControllerName]] #6
] Unflatten remaining downstream referencesSome participation and oversight from the feature teams will be necessary to ensure acceptance criteria (see below) are satisfied.
Some smaller PRs or controllers could be merged together, while larger controllers may require the full 6 PRs. TBD on a case-by-case basis.
3. Clean-up temporary measures
Unflattening #5
] [EPIC] Fix selector state types to use composition and inferenceUnflattening #6
] Update test mocks to remove exhaustive default state spreading.Unflattening #7
] Update hooks and components to remove exhaustive default state spreading.Deprecated "feature branch" approach
1. Upstream
metamask
slice. #296012. Redux
metamask
slice. #296033. Downstream
metamask
slice #29608state\.metamask\.(?!(\w+Controller|AccountTracker|SnapsRegistry))
*.ts, *.tsx, *.js, *.jsx, *.json
*.test.*
Scenario
No response
Design
No response
Technical Details
Doesn't the Redux team recommend normalizing state?
It also suggests organizing state by entity/domain (instead of turning it into a soup of unrelated properties 😜).
Reviews, reviews, reviews
Refine feature branch into independently testable shards
The current approach of merging the entire refactor at once has been determined to be too risky. The epic needs to be reorganized so that it can be reviewed, tested, and merged in smaller chunks (grouped by controller and/or domain).
The previous estimate of 1 month to completion is now revised. The new goal will be 1 month to implement this reorganization, and end of Q1 or later for completion. Overall, this will increase total project duration, but not significantly beyond the time estimate for having taken the revised approach from the beginning.
createSelector
will be extracted to a separate ticket.metamask
slice.metamask
slice.Previous discussion: Is this an "all or nothing" task?
acceptedrejected] Feature branchmain
is a challenge, but has so far been manageable.rejectedaccepted] “Horizontal sharding”: Unflatten one controller state at a time.metamask
slice structure is inconsistent and in flux.metamask
slice as is, and apply changes to a new temporary slice one PR at a time, and then replace themetamask
slice at the end.metamask
slice properties to a new unflattened slice one controller at a time.Converting selectors to TypeScript
Motivation
section of refactor: Unflatten selectors and convert to TypeScript #29014Q1 2025 Non-OKR Priority-1 (Convert [100]% of strategic files to Typescript)
.Motivation
section of chore: Bumpreselect
to^5.1.1
for heterogeneously-typed selectors support #29094Threat Modeling Framework
No response
Acceptance Criteria
metamask
slice properties are updated to be nested under their correct parent controllers.Stakeholder review needed before the work gets merged
References
metamask
slice toappState
slice #28703MetamaskController
stores #28723metamask
Redux slice and convert to TypeScript #28929reselect
to^5.1.1
for heterogeneously-typed selectors support #29094Bridge{,Status}Controller
state #29443The text was updated successfully, but these errors were encountered: