Skip to content
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

chore: Migrate AsyncStorage to mmkv #10153

Open
wants to merge 20 commits into
base: main
Choose a base branch
from
Open

chore: Migrate AsyncStorage to mmkv #10153

wants to merge 20 commits into from

Conversation

kylanhurt
Copy link
Contributor

@kylanhurt kylanhurt commented Jun 27, 2024

Description

While debugging a sqlite error related to AsyncStorage (surpassing storage limit on Android) we have decided to migrate from AsyncStorage to mmkv due to it not having said issue and also for performance reasons. This includes an actual migration of any existing items saved in AsyncStorage to mmkv

Related issues

Fixes: https://github.com/orgs/MetaMask/projects/60/views/6?pane=issue&itemId=63268337

Manual testing steps

  1. Start a fresh install
  2. Create new wallet and set password, etc
  3. Reboot app and see if it gives you normal EXISTING_USER flow (since that value is taken from mmkv now)

Screenshots/Recordings

Should be no discernible different in application behavior.

Pre-merge author checklist

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.

@kylanhurt kylanhurt added team-mobile-platform Run Smoke E2E Triggers smoke e2e on Bitrise labels Jun 27, 2024
Copy link
Contributor

CLA Signature Action: All authors have signed the CLA. You may need to manually re-run the blocking PR check if it doesn't pass in a few minutes.

@kylanhurt kylanhurt changed the title Kylan/mmkv final Migrate AsyncStorage to mmkv Jun 28, 2024
@kylanhurt kylanhurt added Run Smoke E2E Triggers smoke e2e on Bitrise and removed Run Smoke E2E Triggers smoke e2e on Bitrise labels Jun 28, 2024
@kylanhurt kylanhurt changed the title Migrate AsyncStorage to mmkv chore: Migrate AsyncStorage to mmkv Jun 28, 2024
@kylanhurt kylanhurt marked this pull request as ready for review June 28, 2024 18:02
@kylanhurt kylanhurt requested a review from a team as a code owner June 28, 2024 18:02
@kylanhurt kylanhurt linked an issue Jun 28, 2024 that may be closed by this pull request
@kylanhurt kylanhurt added Run Smoke E2E Triggers smoke e2e on Bitrise and removed Run Smoke E2E Triggers smoke e2e on Bitrise labels Jul 1, 2024
app/store/async-storage-wrapper.js Outdated Show resolved Hide resolved
app/store/async-storage-wrapper.js Outdated Show resolved Hide resolved
app/store/async-storage-wrapper.js Outdated Show resolved Hide resolved
app/store/migrations/049.test.ts Show resolved Hide resolved
app/store/migrations/049.ts Outdated Show resolved Hide resolved
app/store/migrations/049.ts Outdated Show resolved Hide resolved
@kylanhurt
Copy link
Contributor Author

Proof of proper migration via simulator, pardon the data structure difference (array vs object).

AsyncStorage before:

[
  ["@MetaMask:CurrentAppVersion", "7.24.4"],
  ["@MetaMask:LastAppVersion", "7.24.4"],
  ["@MetaMask:UserTermsAcceptedv1.0", "true"],
  ["@MetaMask:existingUser", "true"],
  [
    "TEB8xv152IJn8FFTpVwm0XFFNpczkpcr-context",
    "{\"context\":{\"app\":{\"build\":\"1354\",\"name\":\"MetaMask\",\"namespace\":\"io.metamask\",\"version\":\"7.24.4\"},\"device\":{\"manufacturer\":\"Google\",\"model\":\"sdk_gphone64_arm64\",\"name\":\"emu64a\",\"type\":\"android\"},\"library\":{\"name\":\"@segment/analytics-react-native\",\"version\":\"2.17.0\"},\"locale\":\"en-US\",\"network\":{\"cellular\":false,\"wifi\":true},\"os\":{\"name\":\"Android\",\"version\":\"14\"},\"screen\":{\"width\":1440,\"height\":2476,\"density\":3.5},\"timezone\":\"America/Guayaquil\",\"traits\":{},\"instanceId\":\"4cebbbd0-b6e4-48dc-ad7e-4c46ff43634e\"}}"
  ],
  ["TEB8xv152IJn8FFTpVwm0XFFNpczkpcr-events", "{\"events\":[]}"],
  ["TEB8xv152IJn8FFTpVwm0XFFNpczkpcr-filters", "{}"],
  [
    "TEB8xv152IJn8FFTpVwm0XFFNpczkpcr-settings",
    "{\"settings\":{\"Mixpanel (Actions)\":{\"versionSettings\":{\"componentTypes\":[]}},\"Segment.io\":{\"apiKey\":\"TEB8xv152IJn8FFTpVwm0XFFNpczkpcr\",\"unbundledIntegrations\":[],\"addBundledMetadata\":true,\"maybeBundledConfigIds\":{},\"versionSettings\":{\"version\":\"4.4.7\",\"componentTypes\":[\"browser\"]}}}}"
  ],
  [
    "TEB8xv152IJn8FFTpVwm0XFFNpczkpcr-userInfo",
    "{\"userInfo\":{\"anonymousId\":\"0x0000000000000000\",\"userId\":\"8e54e270-0f87-4031-8413-103a86dcff18\",\"traits\":{\"has_marketing_consent\":true,\"is_metrics_opted_in\":true,\"platform\":\"android\",\"currentBuildNumber\":\"1354\",\"applicationVersion\":\"7.24.4\",\"operatingSystemVersion\":\"34\",\"deviceBrand\":\"google\",\"Enable OpenSea API\":\"ON\",\"NFT Autodetection\":\"ON\",\"Theme\":\"light\",\"token_detection_enable\":\"ON\",\"Batch account balance requests\":\"ON\",\"security_providers\":\"blockaid\",\"Authentication Type\":\"password\"}}}"
  ],
  [
    "wc@2:core:0.3//keychain",
    "{\"client_ed25519_seed\":\"bdc8d01ddc1066bcaa6f3b09d602da6f38ab125e37abce1848d42cfe018b3bc5\"}"
  ]
]

mmkv after:

{
  "@MetaMask:CurrentAppVersion": "7.24.4",
  "@MetaMask:LastAppVersion": "7.24.4",
  "@MetaMask:UserTermsAcceptedv1.0": "true",
  "@MetaMask:WhatsNewAppVersionSeen": "7.24.4",
  "@MetaMask:existingUser": "true",
  "TEB8xv152IJn8FFTpVwm0XFFNpczkpcr-context": "{\"context\":{\"app\":{\"build\":\"1354\",\"name\":\"MetaMask\",\"namespace\":\"io.metamask\",\"version\":\"7.24.4\"},\"device\":{\"manufacturer\":\"Google\",\"model\":\"sdk_gphone64_arm64\",\"name\":\"emu64a\",\"type\":\"android\"},\"library\":{\"name\":\"@segment/analytics-react-native\",\"version\":\"2.17.0\"},\"locale\":\"en-US\",\"network\":{\"cellular\":false,\"wifi\":true},\"os\":{\"name\":\"Android\",\"version\":\"14\"},\"screen\":{\"width\":1440,\"height\":2476,\"density\":3.5},\"timezone\":\"America/Guayaquil\",\"traits\":{},\"instanceId\":\"4cebbbd0-b6e4-48dc-ad7e-4c46ff43634e\"}}",
  "TEB8xv152IJn8FFTpVwm0XFFNpczkpcr-events": "{\"events\":[]}",
  "TEB8xv152IJn8FFTpVwm0XFFNpczkpcr-filters": "{}",
  "TEB8xv152IJn8FFTpVwm0XFFNpczkpcr-settings": "{\"settings\":{\"Mixpanel (Actions)\":{\"versionSettings\":{\"componentTypes\":[]}},\"Segment.io\":{\"apiKey\":\"TEB8xv152IJn8FFTpVwm0XFFNpczkpcr\",\"unbundledIntegrations\":[],\"addBundledMetadata\":true,\"maybeBundledConfigIds\":{},\"versionSettings\":{\"version\":\"4.4.7\",\"componentTypes\":[\"browser\"]}}}}",
  "TEB8xv152IJn8FFTpVwm0XFFNpczkpcr-userInfo": "{\"userInfo\":{\"anonymousId\":\"0x0000000000000000\",\"userId\":\"8e54e270-0f87-4031-8413-103a86dcff18\",\"traits\":{\"has_marketing_consent\":true,\"is_metrics_opted_in\":true,\"platform\":\"android\",\"currentBuildNumber\":\"1354\",\"applicationVersion\":\"7.24.4\",\"operatingSystemVersion\":\"34\",\"deviceBrand\":\"google\",\"Enable OpenSea API\":\"ON\",\"NFT Autodetection\":\"ON\",\"Theme\":\"light\",\"token_detection_enable\":\"ON\",\"Batch account balance requests\":\"ON\",\"security_providers\":\"blockaid\",\"Authentication Type\":\"password\"}}}",
  "wc@2:core:0.3//keychain": "{\"client_ed25519_seed\":\"bdc8d01ddc1066bcaa6f3b09d602da6f38ab125e37abce1848d42cfe018b3bc5\"}"
}

@MetaMask MetaMask deleted a comment from github-actions bot Jul 3, 2024
@kylanhurt kylanhurt added Run Smoke E2E Triggers smoke e2e on Bitrise and removed Run Smoke E2E Triggers smoke e2e on Bitrise labels Jul 3, 2024
Copy link
Contributor

github-actions bot commented Jul 3, 2024

https://bitrise.io/ Bitrise

✅✅✅ pr_smoke_e2e_pipeline passed on Bitrise! ✅✅✅

Commit hash: 05ce522
Build link: https://app.bitrise.io/app/be69d4368ee7e86d/pipelines/378b1173-4c58-480d-804d-e4acaa26a914

Note

  • You can kick off another pr_smoke_e2e_pipeline on Bitrise by removing and re-applying the Run Smoke E2E label on the pull request

@kylanhurt kylanhurt added Run Smoke E2E Triggers smoke e2e on Bitrise and removed Run Smoke E2E Triggers smoke e2e on Bitrise labels Jul 3, 2024
@kylanhurt kylanhurt added the needs-dev-review PR needs reviews from other engineers (in order to receive required approvals) label Jul 3, 2024
tommasini
tommasini previously approved these changes Jul 3, 2024
Copy link
Contributor

@tommasini tommasini left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@kylanhurt kylanhurt added Run Smoke E2E Triggers smoke e2e on Bitrise and removed Run Smoke E2E Triggers smoke e2e on Bitrise labels Jul 3, 2024
Copy link
Contributor

github-actions bot commented Jul 3, 2024

https://bitrise.io/ Bitrise

✅✅✅ pr_smoke_e2e_pipeline passed on Bitrise! ✅✅✅

Commit hash: 4b0e45a
Build link: https://app.bitrise.io/app/be69d4368ee7e86d/pipelines/dbcb1549-49cc-4d25-a015-eeef0dd2db4b

Note

  • You can kick off another pr_smoke_e2e_pipeline on Bitrise by removing and re-applying the Run Smoke E2E label on the pull request

vinistevam
vinistevam previously approved these changes Jul 4, 2024
Copy link
Contributor

@vinistevam vinistevam left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great PR!
One small question, Will the renaming of async-storage-wrapper.js be handled in a separate ticket?

Copy link
Contributor

@tommasini tommasini left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm wondering if we should clear all the async storage, after migrating
https://react-native-async-storage.github.io/async-storage/docs/api#clear

WDYT?

app/store/migrations/049.ts Outdated Show resolved Hide resolved
@kylanhurt kylanhurt dismissed stale reviews from vinistevam and tommasini via f002f17 July 4, 2024 14:40
@kylanhurt kylanhurt added Run Smoke E2E Triggers smoke e2e on Bitrise and removed Run Smoke E2E Triggers smoke e2e on Bitrise labels Jul 4, 2024
Copy link
Contributor

github-actions bot commented Jul 4, 2024

https://bitrise.io/ Bitrise

✅✅✅ pr_smoke_e2e_pipeline passed on Bitrise! ✅✅✅

Commit hash: f002f17
Build link: https://app.bitrise.io/app/be69d4368ee7e86d/pipelines/bb105bbc-9a60-4c90-be5e-2d118788dbd8

Note

  • You can kick off another pr_smoke_e2e_pipeline on Bitrise by removing and re-applying the Run Smoke E2E label on the pull request

Copy link

sonarcloud bot commented Jul 4, 2024

@kylanhurt kylanhurt added Run Smoke E2E Triggers smoke e2e on Bitrise and removed Run Smoke E2E Triggers smoke e2e on Bitrise labels Jul 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-dev-review PR needs reviews from other engineers (in order to receive required approvals) Run Smoke E2E Triggers smoke e2e on Bitrise team-mobile-platform
Projects
Status: Review finalised - Ready to be merged
Development

Successfully merging this pull request may close these issues.

[Sentry] Error: database or disk is full (code 13 SQLITE_FULL)
3 participants