MetaMask / metamask-mobile

Mobile web browser providing access to websites that use the Ethereum blockchain
https://metamask.io
Other
2.04k stars 1.06k forks source link

chore: Migrate AsyncStorage to mmkv #10153

Open kylanhurt opened 5 days ago

kylanhurt commented 5 days ago

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

github-actions[bot] commented 5 days ago

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.

github-actions[bot] commented 7 hours ago

https://bitrise.io/ Bitrise

❌❌❌ pr_smoke_e2e_pipeline failed on Bitrise! ❌❌❌

Commit hash: fff043d77bd401f22cda913484ba93c67267935f Build link: https://app.bitrise.io/app/be69d4368ee7e86d/pipelines/5041ec5a-ffb2-4979-82a5-b6df63c4e585

[!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
sonarcloud[bot] commented 7 hours ago

Quality Gate Passed Quality Gate passed

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
82.1% Coverage on New Code
0.0% Duplication on New Code

See analysis details on SonarCloud

kylanhurt commented 6 hours ago

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\"}"
}