Skip to content

Conversation

Kriys94
Copy link
Contributor

@Kriys94 Kriys94 commented Oct 13, 2025

Description

This PR integrates the Backend WebSocket Service and Account Activity Service from @metamask/core-backend into MetaMask Extension. These services enable real-time account activity monitoring and balance updates via WebSocket connections.

⚠️ Important: This integration is feature-flagged and will NOT change any behavior until the backendWebSocketConnection remote feature flag is enabled. Without the feature flag, the WebSocket service will not connect, and the extension will continue to work exactly as before.

What is the reason for the change?

To prepare the extension for real-time account activity updates from the MetaMask backend platform, reducing reliance on polling and enabling faster balance updates and transaction notifications.

What is the improvement/solution?

  1. Integrated BackendWebSocketService: Provides authenticated WebSocket connectivity to the MetaMask backend with automatic reconnection, authentication flow integration, and feature flag control.

  2. Integrated AccountActivityService: Subscribes to account activity channels and receives real-time transaction and balance updates.

  3. TokenBalancesController Integration: The controller automatically adjusts polling intervals based on WebSocket availability:

    • When chains are "up" (WebSocket active): Reduces polling to 5 minutes (backup only)
    • When chains are "down" (WebSocket inactive): Uses default 30-second polling
    • Automatically imports new tokens detected via WebSocket balance updates
  4. Package Updates: Updated to use local @metamask/core-backend and @metamask/assets-controllers packages from the core monorepo for development.

Architecture

BackendWebSocketService (Transport Layer)

AccountActivityService (Data Layer)

TokenBalancesController & AccountTrackerController, TokenDetectionController (Business Logic, and internal state Management)

References

For detailed architecture, implementation details, and API documentation, see:

Changelog

CHANGELOG entry: Integrated Backend WebSocket Service and Account Activity Service for real-time balance updates (feature-flagged)

Related issues

Fixes: [Add issue number]

Manual testing steps

Since this feature is behind a feature flag, testing requires enabling the flag:

Testing with Feature Flag Disabled (Default)

  1. Build and run the extension
  2. Verify extension works normally
  3. Confirm no WebSocket connections are made (check Network tab)
  4. Verify token balances still update via polling

Testing with Feature Flag Enabled (Development)

  1. Add to .metamaskrc:
BACKEND_WEBSOCKET_CONNECTION_ENABLED=true
  1. Build and run the extension
  2. Unlock wallet
  3. Check browser console for WebSocket connection logs: [BackendWebSocketService]
  4. Verify WebSocket connection in Network tab (wss://gateway.dev-api.cx.metamask.io/v1)
  5. Perform transactions and verify balance updates
  6. Check that TokenBalancesController logs show adjusted polling intervals

Screenshots/Recordings

Before

N/A - This is a new feature integration

After

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.

Technical Details

Files Added

  • app/scripts/controller-init/core-backend/backend-websocket-service-init.ts - Service initialization with feature flag and auth integration
  • app/scripts/controller-init/core-backend/account-activity-service-init.ts - Account activity service setup
  • app/scripts/controller-init/messengers/core-backend/backend-websocket-service-messenger.ts - Messenger with auth actions/events
  • app/scripts/controller-init/messengers/core-backend/account-activity-service-messenger.ts - Account activity messenger
  • Index files for exports

Files Modified

  • package.json - Added @metamask/core-backend and switched @metamask/assets-controllers to local file reference
  • builds.yml - Environment variables for WebSocket URL (already present)
  • controller-list.ts - Added service types
  • messengers/index.ts - Registered service messengers
  • metamask-controller.js - Integrated services into controller initialization
  • messengers/token-balances-controller-messenger.ts - Added actions/events for WebSocket integration
  • yarn.lock - Updated dependencies

Integration Points

TokenBalancesController (in core) automatically:

  • Subscribes to AccountActivityService:statusChanged for dynamic polling adjustment
  • Subscribes to AccountActivityService:balanceUpdated for real-time balance updates
  • Calls TokenDetectionController:addDetectedTokensViaWs to auto-import new tokens

BackendWebSocketService handles:

  • Feature flag checking (backendWebSocketConnection remote feature flag)
  • Authentication via AuthenticationController:getBearerToken
  • Wallet lock/unlock state monitoring
  • Automatic reconnection with exponential backoff

AccountActivityService provides:

  • Automatic subscription to selected account
  • Account switching handling
  • Balance update processing with CAIP-10 format support
  • Chain status tracking and notification

<!-- CURSOR_SUMMARY -->
---

> [!NOTE]
> Integrates feature-flagged backend WebSocket and AccountActivity services, wires them into controllers/messengers with real-time balance updates, and updates configs, policies, and deps.
> 
> - **Core Backend Integration**:
>   - Add `BackendWebSocketServiceInit` and `AccountActivityServiceInit` with feature-flag gating via `RemoteFeatureFlagController:getState` and tracing.
>   - Register services in `controller-list.ts`, `controller-init/index`, and `metamask-controller.js` (connect/disconnect on UI open/close).
> - **Controllers & Messaging**:
>   - New messengers for `BackendWebSocketService` and `AccountActivityService` with auth and lifecycle events; expose in `messengers/index.ts`.
>   - Extend `TokenBalancesController` messengers to handle `AccountActivityService` events and `TokenDetectionController:addDetectedTokensViaWs`.
>   - Update `AccountTrackerController.updateNativeBalances` to normalize addresses to lowercase.
> - **Config**:
>   - Add `MM_BACKEND_WEBSOCKET_URL` (default `wss://gateway.api.cx.metamask.io/v1`) in `.metamaskrc.dist` and `builds.yml`.
> - **Security/Policies**:
>   - LavaMoat policies: allow `@metamask/core-backend` globals (`URL`, `WebSocket`, timers) and packages.
> - **Dependencies**:
>   - Add `@metamask/core-backend@^2.1.0`; bump `@metamask/assets-controllers` to `81.0.0` (patch), update related locks; bump `@metamask/bridge-status-controller` and `@metamask/profile-sync-controller`.
> - **Tests**:
>   - Add init and messenger tests for core-backend services, including feature-flag `isEnabled` behavior.
> 
> <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit c66db6bb80960e9f2ccf474d098ccbecd639211e. This will update automatically on new commits. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->

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.

@Kriys94 Kriys94 force-pushed the feature/core-backend branch from 971905c to f27a63e Compare October 13, 2025 15:09
@github-actions github-actions bot added size-L and removed size-M labels Oct 13, 2025
Copy link

socket-security bot commented Oct 13, 2025

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Added@​metamask/​core-backend@​2.1.07710010092100
Updated@​metamask/​bridge-status-controller@​50.0.0 ⏵ 50.1.0991007898 +1100
Added@​metamask/​profile-sync-controller@​25.1.1991008797100
Updated@​metamask/​assets-controllers@​79.0.0 ⏵ 81.0.09810091 +198 +1100

View full report

Copy link

socket-security bot commented Oct 13, 2025

Warning

MetaMask internal reviewing guidelines:

  • Do not ignore-all
  • Each alert has instructions on how to review if you don't know what it means. If lost, ask your Security Liaison or the supply-chain group
  • Copy-paste ignore lines for specific packages or a group of one kind with a note on what research you did to deem it safe.
    @SocketSecurity ignore npm/PACKAGE@VERSION
Action Severity Alert  (click "▶" to expand/collapse)
Warn Low
@metamask/[email protected] is a AI-detected potential code anomaly.

Notes: The code implements a guarded, cache-accelerated path to sign a message via an external SnapController. No explicit malware indicators detected. Primary risks relate to API design and cache semantics: entropySourceId is currently unused in the cache key, which could cause mismatches between the signing policy and cached signatures; potential replay/reuse concerns if identical messages are signed for different intents without provenance. Recommended improvements: validate message format and provenance, incorporate entropySourceId into cache keys or policy checks, add audit logging, and implement cache eviction/invalidation rules to prevent stale signatures.

Confidence: 0.75

Severity: 0.55

From: package.jsonnpm/@metamask/[email protected]

ℹ Read more on: This package | This alert | What is an AI-detected potential code anomaly?

Next steps: Take a moment to review the security alert above. Review the linked package source code to understand the potential risk. Ensure the package is not malicious before proceeding. If you're unsure how to proceed, reach out to your security team or ask the Socket team for help at [email protected].

Suggestion: An AI system found a low-risk anomaly in this package. It may still be fine to use, but you should check that it is safe before proceeding.

Mark the package as acceptable risk. To ignore this alert only in this pull request, reply with the comment @SocketSecurity ignore npm/@metamask/[email protected]. You can also ignore all packages with @SocketSecurity ignore-all. To ignore an alert for all future pull requests, use Socket's Dashboard to change the triage state of this alert.

View full report

@Kriys94 Kriys94 added team-extension-platform Extension Platform team team-assets labels Oct 13, 2025
@Kriys94 Kriys94 force-pushed the feature/core-backend branch 2 times, most recently from 0492257 to 7cf06e9 Compare October 13, 2025 23:45
@metamaskbot
Copy link
Collaborator

📊 Page Load Benchmark Results

Current Commit: 7cf06e9 | Date: 10/14/2025

📄 Localhost MetaMask Test Dapp

Samples: 100

Summary

  • pageLoadTime-> current mean value: 1.07s (±76ms) 🟡 | historical mean value: 1.05s ⬆️ (historical data)
  • domContentLoaded-> current mean value: 751ms (±72ms) 🟢 | historical mean value: 739ms ⬆️ (historical data)
  • firstContentfulPaint-> current mean value: 80ms (±14ms) 🟢 | historical mean value: 77ms ⬆️ (historical data)
📈 Detailed Results
Metric Mean Std Dev Min Max P95 P99
pageLoadTime 1.07s 76ms 1.03s 1.37s 1.30s 1.37s
domContentLoaded 751ms 72ms 713ms 1.05s 976ms 1.05s
firstPaint 80ms 14ms 64ms 208ms 92ms 208ms
firstContentfulPaint 80ms 14ms 64ms 208ms 92ms 208ms
largestContentfulPaint 0ms 0ms 0ms 0ms 0ms 0ms

Results generated automatically by MetaMask CI

@metamaskbot
Copy link
Collaborator

Builds ready [7cf06e9]
UI Startup Metrics (1208 ± 69 ms)
PlatformBuildTypePageMetricMean (ms)Min (ms)Max (ms)Std Dev (ms)P 75 (ms)P 95 (ms)
ChromeBrowserifyHomeuiStartup1208110116566912371306
load104494814706510711118
domContentLoaded103794414636410661113
domInteractive1913136161737
firstPaint72878112641310691118
backgroundConnect25023539016253265
firstReactRender2517129112537
getState1154661423
initialActions50245616
loadScripts794697122965824871
setupStore96264918
WebpackHomeuiStartup8547321095708671060
load65860293575663831
domContentLoaded65059691373655824
domInteractive17125481536
firstPaint23157944231201788
backgroundConnect22114272635
firstReactRender27174573335
getState842231013
initialActions2011236
loadScripts64759490271653813
setupStore84172912
FirefoxBrowserifyHomeuiStartup15491355222516116081951
load1301114116349713741472
domContentLoaded1301114016349713741471
domInteractive1063529556109256
firstPaintNaNNaNNaNNaNNaNNaN
backgroundConnect3622122174073
firstReactRender34276863648
getState9410215733
initialActions12023239345
loadScripts1273112315229113401448
setupStore13412919851
WebpackHomeuiStartup14661327199011514891765
load1276113115997213141400
domContentLoaded1275113115997213131399
domInteractive87312903993175
firstPaintNaNNaNNaNNaNNaNNaN
backgroundConnect3017148173255
firstReactRender342374133570
getState7313114616
initialActions2035427
loadScripts1252111414706512871372
setupStore12314021769
Bundle size diffs [🚀 Bundle size reduced!]
  • background: 40.53 KiB (0.89%)
  • ui: 5.09 KiB (0.08%)
  • common: -40.63 KiB (-0.49%)

@Kriys94 Kriys94 force-pushed the feature/core-backend branch from 7cf06e9 to db89d40 Compare October 14, 2025 00:26
@metamaskbot
Copy link
Collaborator

❌ test-e2e-chrome-api-specs failed. View the html report here.

@metamaskbot
Copy link
Collaborator

📊 Page Load Benchmark Results

Current Commit: db89d40 | Date: 10/14/2025

📄 Localhost MetaMask Test Dapp

Samples: 100

Summary

  • pageLoadTime-> current mean value: 1.06s (±71ms) 🟡 | historical mean value: 1.05s ⬆️ (historical data)
  • domContentLoaded-> current mean value: 743ms (±70ms) 🟢 | historical mean value: 739ms ⬆️ (historical data)
  • firstContentfulPaint-> current mean value: 79ms (±10ms) 🟢 | historical mean value: 77ms ⬆️ (historical data)
📈 Detailed Results
Metric Mean Std Dev Min Max P95 P99
pageLoadTime 1.06s 71ms 1.02s 1.34s 1.28s 1.34s
domContentLoaded 743ms 70ms 707ms 1.03s 951ms 1.03s
firstPaint 79ms 10ms 60ms 164ms 88ms 164ms
firstContentfulPaint 79ms 10ms 60ms 164ms 88ms 164ms
largestContentfulPaint 0ms 0ms 0ms 0ms 0ms 0ms

Results generated automatically by MetaMask CI

@metamaskbot
Copy link
Collaborator

Builds ready [db89d40]
UI Startup Metrics (1239 ± 81 ms)
PlatformBuildTypePageMetricMean (ms)Min (ms)Max (ms)Std Dev (ms)P 75 (ms)P 95 (ms)
ChromeBrowserifyHomeuiStartup1239108816798112751356
load106796115217610971191
domContentLoaded106195615177610911186
domInteractive18135071739
firstPaint65485123842110571130
backgroundConnect2512382768256265
firstReactRender2919166202844
getState1053451221
initialActions40265613
loadScripts816712127975845930
setupStore1053751024
WebpackHomeuiStartup8176961149818231016
load63657798185635860
domContentLoaded62956996284629850
domInteractive15115791439
firstPaint18555991182191596
backgroundConnect20103862532
firstReactRender25165983033
getState832031018
initialActions2015226
loadScripts62756895182628839
setupStore74132911
FirefoxBrowserifyHomeuiStartup14031231175411514611643
load1205107114268212671349
domContentLoaded1205107114268212671348
domInteractive1023430052107244
firstPaintNaNNaNNaNNaNNaNNaN
backgroundConnect291994123250
firstReactRender29245753039
getState739210619
initialActions30698214
loadScripts1183105114048012521316
setupStore10414117743
WebpackHomeuiStartup15541347197812715931829
load13571203171810014181551
domContentLoaded13571202171810014181550
domInteractive1043039274105333
firstPaintNaNNaNNaNNaNNaNNaN
backgroundConnect3016113143444
firstReactRender34258493642
getState53384511
initialActions5013015224
loadScripts1333118716949913921513
setupStore11411017755
Bundle size diffs [🚀 Bundle size reduced!]
  • background: 40.53 KiB (0.89%)
  • ui: 5.09 KiB (0.08%)
  • common: -40.63 KiB (-0.49%)

@Kriys94 Kriys94 force-pushed the feature/core-backend branch from db89d40 to 8652c12 Compare October 14, 2025 09:59
@metamaskbot
Copy link
Collaborator

📊 Page Load Benchmark Results

Current Commit: 8652c12 | Date: 10/14/2025

📄 Localhost MetaMask Test Dapp

Samples: 100

Summary

  • pageLoadTime-> current mean value: 1.06s (±72ms) 🟡 | historical mean value: 1.05s ⬆️ (historical data)
  • domContentLoaded-> current mean value: 742ms (±69ms) 🟢 | historical mean value: 735ms ⬆️ (historical data)
  • firstContentfulPaint-> current mean value: 78ms (±12ms) 🟢 | historical mean value: 77ms ⬆️ (historical data)
📈 Detailed Results
Metric Mean Std Dev Min Max P95 P99
pageLoadTime 1.06s 72ms 1.02s 1.32s 1.32s 1.32s
domContentLoaded 742ms 69ms 706ms 1.00s 974ms 1.00s
firstPaint 78ms 12ms 60ms 176ms 88ms 176ms
firstContentfulPaint 78ms 12ms 60ms 176ms 88ms 176ms
largestContentfulPaint 0ms 0ms 0ms 0ms 0ms 0ms

Results generated automatically by MetaMask CI

@metamaskbot
Copy link
Collaborator

Builds ready [8652c12]
UI Startup Metrics (1277 ± 89 ms)
PlatformBuildTypePageMetricMean (ms)Min (ms)Max (ms)Std Dev (ms)P 75 (ms)P 95 (ms)
ChromeBrowserifyHomeuiStartup1277109016458913221435
load109396214408011421245
domContentLoaded108695714358011321241
domInteractive1914127131832
firstPaint65690123843710871186
backgroundConnect25824231311260286
firstReactRender2819132133043
getState14585121538
initialActions40265513
loadScripts834715115278882984
setupStore1062551122
WebpackHomeuiStartup8377051515100870991
load6575701371109674853
domContentLoaded6505641353107663846
domInteractive16116491438
firstPaint188571391207189610
backgroundConnect20103562531
firstReactRender2616164163134
getState841731013
initialActions2013236
loadScripts6485611343106661839
setupStore74132911
FirefoxBrowserifyHomeuiStartup13681225174410814131599
load1170105014587812311293
domContentLoaded1170104914587812311293
domInteractive1003229554104247
firstPaintNaNNaNNaNNaNNaNNaN
backgroundConnect2819128143247
firstReactRender29257863038
getState73488530
initialActions4013415217
loadScripts1149103314257712071276
setupStore947412741
WebpackHomeuiStartup15491355191710616001769
load1354119816788214001518
domContentLoaded1354119816788214001518
domInteractive1033135364103337
firstPaintNaNNaNNaNNaNNaNNaN
backgroundConnect3118165183552
firstReactRender34268293644
getState62405614
initialActions607616254
loadScripts1329118015177613721492
setupStore84497624
Bundle size diffs [🚨 Warning! Bundle size has increased!]
  • background: 40.43 KiB (0.89%)
  • ui: 7.29 KiB (0.11%)
  • common: -40.18 KiB (-0.48%)

@Kriys94 Kriys94 force-pushed the feature/core-backend branch from 8652c12 to d964c60 Compare October 14, 2025 10:32
@metamaskbot
Copy link
Collaborator

📊 Page Load Benchmark Results

Current Commit: d964c60 | Date: 10/14/2025

📄 Localhost MetaMask Test Dapp

Samples: 100

Summary

  • pageLoadTime-> current mean value: 1.05s (±71ms) 🟡 | historical mean value: 1.05s ⬇️ (historical data)
  • domContentLoaded-> current mean value: 733ms (±68ms) 🟢 | historical mean value: 735ms ⬇️ (historical data)
  • firstContentfulPaint-> current mean value: 75ms (±13ms) 🟢 | historical mean value: 77ms ⬇️ (historical data)
📈 Detailed Results
Metric Mean Std Dev Min Max P95 P99
pageLoadTime 1.05s 71ms 1.01s 1.32s 1.26s 1.32s
domContentLoaded 733ms 68ms 697ms 1000ms 941ms 1000ms
firstPaint 75ms 13ms 56ms 184ms 88ms 184ms
firstContentfulPaint 75ms 13ms 56ms 184ms 88ms 184ms
largestContentfulPaint 0ms 0ms 0ms 0ms 0ms 0ms

Results generated automatically by MetaMask CI

@metamaskbot
Copy link
Collaborator

Builds ready [d964c60]
UI Startup Metrics (1235 ± 65 ms)
PlatformBuildTypePageMetricMean (ms)Min (ms)Max (ms)Std Dev (ms)P 75 (ms)P 95 (ms)
ChromeBrowserifyHomeuiStartup1235109413816512801359
load106696412196411181183
domContentLoaded106095512146411081178
domInteractive18146991749
firstPaint63873122343710751170
backgroundConnect2512372807254267
firstReactRender25184452639
getState1156771320
initialActions40355514
loadScripts81571196263857931
setupStore95284919
WebpackHomeuiStartup8247021066738441003
load64257791479644844
domContentLoaded63457190378636837
domInteractive16115391438
firstPaint18154908166189592
backgroundConnect2110106112533
firstReactRender261771103135
getState73153913
initialActions2012236
loadScripts63157089376635825
setupStore84162911
FirefoxBrowserifyHomeuiStartup14091216186713614751756
load1199105614008612581354
domContentLoaded1198105613998612581353
domInteractive1003331957100243
firstPaintNaNNaNNaNNaNNaNNaN
backgroundConnect3119189213451
firstReactRender29254433138
getState726211538
initialActions4012713217
loadScripts1176104113738212341331
setupStore144195327104
WebpackHomeuiStartup15351346214212615741776
load1334120116548613821505
domContentLoaded1333120016548613811505
domInteractive1023443566101318
firstPaintNaNNaNNaNNaNNaNNaN
backgroundConnect3018122153452
firstReactRender372687143775
getState7214816515
initialActions6019722239
loadScripts1310118216298413531480
setupStore1046613745
Bundle size diffs [🚨 Warning! Bundle size has increased!]
  • background: 40.43 KiB (0.89%)
  • ui: 7.37 KiB (0.11%)
  • common: -40.18 KiB (-0.48%)

@Kriys94 Kriys94 force-pushed the feature/core-backend branch from d964c60 to fc523c2 Compare October 14, 2025 11:23
@metamaskbot
Copy link
Collaborator

📊 Page Load Benchmark Results

Current Commit: fc523c2 | Date: 10/14/2025

📄 Localhost MetaMask Test Dapp

Samples: 100

Summary

  • pageLoadTime-> current mean value: 1.05s (±73ms) 🟡 | historical mean value: 1.05s ⬆️ (historical data)
  • domContentLoaded-> current mean value: 739ms (±71ms) 🟢 | historical mean value: 738ms ⬆️ (historical data)
  • firstContentfulPaint-> current mean value: 76ms (±10ms) 🟢 | historical mean value: 77ms ⬇️ (historical data)
📈 Detailed Results
Metric Mean Std Dev Min Max P95 P99
pageLoadTime 1.05s 73ms 1.01s 1.34s 1.31s 1.34s
domContentLoaded 739ms 71ms 701ms 1.02s 986ms 1.02s
firstPaint 76ms 10ms 60ms 152ms 84ms 152ms
firstContentfulPaint 76ms 10ms 60ms 152ms 84ms 152ms
largestContentfulPaint 0ms 0ms 0ms 0ms 0ms 0ms

Results generated automatically by MetaMask CI

@metamaskbot
Copy link
Collaborator

Builds ready [fc523c2]
UI Startup Metrics (1230 ± 57 ms)
PlatformBuildTypePageMetricMean (ms)Min (ms)Max (ms)Std Dev (ms)P 75 (ms)P 95 (ms)
ChromeBrowserifyHomeuiStartup1230113314155712721354
load105597111965110901151
domContentLoaded104996411935110841146
domInteractive18134761727
firstPaint67486119142910801134
backgroundConnect25223832012256275
firstReactRender25185262637
getState12579111323
initialActions50365615
loadScripts80372595749835894
setupStore95323914
WebpackHomeuiStartup798688104568813943
load61556888763621795
domContentLoaded60756287762614785
domInteractive15117091335
firstPaint18754790173191580
backgroundConnect20114572432
firstReactRender2716126133036
getState84193911
initialActions2011236
loadScripts60456086660613772
setupStore84142911
FirefoxBrowserifyHomeuiStartup14071225202712614651648
load1202106014598412631344
domContentLoaded1201105914598412631343
domInteractive1043430655112262
firstPaintNaNNaNNaNNaNNaNNaN
backgroundConnect291877103345
firstReactRender31256073154
getState63869515
initialActions301321328
loadScripts1180104114338412421324
setupStore11420925731
WebpackHomeuiStartup15151364190510515511715
load1327119416157913681491
domContentLoaded1327119416157913671491
domInteractive98303696995326
firstPaintNaNNaNNaNNaNNaNNaN
backgroundConnect3019111133344
firstReactRender352779113674
getState63496513
initialActions2016329
loadScripts1304117415467613431470
setupStore10413618644
Bundle size diffs [🚨 Warning! Bundle size has increased!]
  • background: 40.42 KiB (0.89%)
  • ui: 7.37 KiB (0.11%)
  • common: -40.18 KiB (-0.48%)

@Kriys94 Kriys94 force-pushed the feature/core-backend branch 2 times, most recently from f912185 to c4f1f2d Compare October 14, 2025 11:55
@metamaskbot
Copy link
Collaborator

📊 Page Load Benchmark Results

Current Commit: c4f1f2d | Date: 10/14/2025

📄 Localhost MetaMask Test Dapp

Samples: 100

Summary

  • pageLoadTime-> current mean value: 1.06s (±72ms) 🟡 | historical mean value: 1.05s ⬆️ (historical data)
  • domContentLoaded-> current mean value: 744ms (±70ms) 🟢 | historical mean value: 738ms ⬆️ (historical data)
  • firstContentfulPaint-> current mean value: 78ms (±13ms) 🟢 | historical mean value: 77ms ⬆️ (historical data)
📈 Detailed Results
Metric Mean Std Dev Min Max P95 P99
pageLoadTime 1.06s 72ms 1.02s 1.34s 1.28s 1.34s
domContentLoaded 744ms 70ms 707ms 1.02s 949ms 1.02s
firstPaint 78ms 13ms 60ms 188ms 96ms 188ms
firstContentfulPaint 78ms 13ms 60ms 188ms 96ms 188ms
largestContentfulPaint 0ms 0ms 0ms 0ms 0ms 0ms

Results generated automatically by MetaMask CI

@metamaskbot
Copy link
Collaborator

✨ Files requiring CODEOWNER review ✨

🧩 @MetaMask/extension-devs (5 files, +60 -0)
  • 📁 lavamoat/
    • 📁 browserify/
      • 📁 beta/
        • 📄 policy.json +12 -0
      • 📁 experimental/
        • 📄 policy.json +12 -0
      • 📁 flask/
        • 📄 policy.json +12 -0
      • 📁 main/
        • 📄 policy.json +12 -0
    • 📁 webpack/
      • 📄 policy.json +12 -0

📜 @MetaMask/policy-reviewers (5 files, +60 -0)
  • 📁 lavamoat/
    • 📁 browserify/
      • 📁 beta/
        • 📄 policy.json +12 -0
      • 📁 experimental/
        • 📄 policy.json +12 -0
      • 📁 flask/
        • 📄 policy.json +12 -0
      • 📁 main/
        • 📄 policy.json +12 -0
    • 📁 webpack/
      • 📄 policy.json +12 -0

Tip

Follow the policy review process outlined in the LavaMoat Policy Review Process doc before expecting an approval from Policy Reviewers.


🔗 @MetaMask/supply-chain (5 files, +60 -0)
  • 📁 lavamoat/
    • 📁 browserify/
      • 📁 beta/
        • 📄 policy.json +12 -0
      • 📁 experimental/
        • 📄 policy.json +12 -0
      • 📁 flask/
        • 📄 policy.json +12 -0
      • 📁 main/
        • 📄 policy.json +12 -0
    • 📁 webpack/
      • 📄 policy.json +12 -0

@Kriys94 Kriys94 force-pushed the feature/core-backend branch from 02b6ca7 to 495360b Compare October 16, 2025 18:58
cursor[bot]

This comment was marked as outdated.

@Kriys94
Copy link
Contributor Author

Kriys94 commented Oct 16, 2025

Bug: Address Case Inconsistency Causes Balance Issues

The updateNativeBalances method now normalizes addresses to lowercase for accountsByChainId state updates, particularly for checksum addresses. However, updateStakedBalances was not updated to match this behavior. This inconsistency can store native and staked balances for the same account under different address casings, potentially causing lookup failures or duplicate entries.

app/scripts/controllers/account-tracker-controller.ts#L1050-L1081

updateStakedBalances(
stakedBalances: {
address: string;
chainId: Hex;
stakedBalance: StakedBalance;
}[],
) {
this.update((state) => {
stakedBalances.forEach(({ address, chainId, stakedBalance }) => {
// Ensure the chainId exists in the state
if (!state.accountsByChainId[chainId]) {
state.accountsByChainId[chainId] = {};
}
// Ensure the address exists for this chain
if (!state.accountsByChainId[chainId][address]) {
state.accountsByChainId[chainId][address] = {
address,
balance: '0x0',
};
}
// Update the staked balance
if (stakedBalance) {
state.accountsByChainId[chainId][address].stakedBalance =
toHex(stakedBalance);
}
});
});
}
/**
* Fetches account balances from the account API service (v4 multiaccount endpoint)
* Supports multichain and multiAccount requests with automatic batching

app/scripts/controllers/account-tracker-controller.ts#L1047-L1041
https://github.com/MetaMask/metamask-extension/blob/02b6ca768f317db09e307e1ba3dded1311331c12/app/scripts/controllers/account-tracker-controller.ts#L1047-L1041

This PR is unrelated to updateStakedBalances, the updateStakedBalances will work as it is today. I will let the ongoing work about moving AccountTracker to core to normalize all balances

@metamaskbot
Copy link
Collaborator

✨ Files requiring CODEOWNER review ✨

🧩 @MetaMask/extension-devs (5 files, +60 -0)
  • 📁 lavamoat/
    • 📁 browserify/
      • 📁 beta/
        • 📄 policy.json +12 -0
      • 📁 experimental/
        • 📄 policy.json +12 -0
      • 📁 flask/
        • 📄 policy.json +12 -0
      • 📁 main/
        • 📄 policy.json +12 -0
    • 📁 webpack/
      • 📄 policy.json +12 -0

📜 @MetaMask/policy-reviewers (5 files, +60 -0)
  • 📁 lavamoat/
    • 📁 browserify/
      • 📁 beta/
        • 📄 policy.json +12 -0
      • 📁 experimental/
        • 📄 policy.json +12 -0
      • 📁 flask/
        • 📄 policy.json +12 -0
      • 📁 main/
        • 📄 policy.json +12 -0
    • 📁 webpack/
      • 📄 policy.json +12 -0

Tip

Follow the policy review process outlined in the LavaMoat Policy Review Process doc before expecting an approval from Policy Reviewers.


🔗 @MetaMask/supply-chain (5 files, +60 -0)
  • 📁 lavamoat/
    • 📁 browserify/
      • 📁 beta/
        • 📄 policy.json +12 -0
      • 📁 experimental/
        • 📄 policy.json +12 -0
      • 📁 flask/
        • 📄 policy.json +12 -0
      • 📁 main/
        • 📄 policy.json +12 -0
    • 📁 webpack/
      • 📄 policy.json +12 -0

@Kriys94 Kriys94 force-pushed the feature/core-backend branch from 495360b to a93caf4 Compare October 16, 2025 19:15
@metamaskbot
Copy link
Collaborator

✨ Files requiring CODEOWNER review ✨

🧩 @MetaMask/extension-devs (5 files, +60 -0)
  • 📁 lavamoat/
    • 📁 browserify/
      • 📁 beta/
        • 📄 policy.json +12 -0
      • 📁 experimental/
        • 📄 policy.json +12 -0
      • 📁 flask/
        • 📄 policy.json +12 -0
      • 📁 main/
        • 📄 policy.json +12 -0
    • 📁 webpack/
      • 📄 policy.json +12 -0

📜 @MetaMask/policy-reviewers (5 files, +60 -0)
  • 📁 lavamoat/
    • 📁 browserify/
      • 📁 beta/
        • 📄 policy.json +12 -0
      • 📁 experimental/
        • 📄 policy.json +12 -0
      • 📁 flask/
        • 📄 policy.json +12 -0
      • 📁 main/
        • 📄 policy.json +12 -0
    • 📁 webpack/
      • 📄 policy.json +12 -0

Tip

Follow the policy review process outlined in the LavaMoat Policy Review Process doc before expecting an approval from Policy Reviewers.


🔗 @MetaMask/supply-chain (5 files, +60 -0)
  • 📁 lavamoat/
    • 📁 browserify/
      • 📁 beta/
        • 📄 policy.json +12 -0
      • 📁 experimental/
        • 📄 policy.json +12 -0
      • 📁 flask/
        • 📄 policy.json +12 -0
      • 📁 main/
        • 📄 policy.json +12 -0
    • 📁 webpack/
      • 📄 policy.json +12 -0

@Kriys94 Kriys94 force-pushed the feature/core-backend branch from a93caf4 to 8d19837 Compare October 16, 2025 19:38
@metamaskbot
Copy link
Collaborator

✨ Files requiring CODEOWNER review ✨

🧩 @MetaMask/extension-devs (5 files, +60 -0)
  • 📁 lavamoat/
    • 📁 browserify/
      • 📁 beta/
        • 📄 policy.json +12 -0
      • 📁 experimental/
        • 📄 policy.json +12 -0
      • 📁 flask/
        • 📄 policy.json +12 -0
      • 📁 main/
        • 📄 policy.json +12 -0
    • 📁 webpack/
      • 📄 policy.json +12 -0

📜 @MetaMask/policy-reviewers (5 files, +60 -0)
  • 📁 lavamoat/
    • 📁 browserify/
      • 📁 beta/
        • 📄 policy.json +12 -0
      • 📁 experimental/
        • 📄 policy.json +12 -0
      • 📁 flask/
        • 📄 policy.json +12 -0
      • 📁 main/
        • 📄 policy.json +12 -0
    • 📁 webpack/
      • 📄 policy.json +12 -0

Tip

Follow the policy review process outlined in the LavaMoat Policy Review Process doc before expecting an approval from Policy Reviewers.


🔗 @MetaMask/supply-chain (5 files, +60 -0)
  • 📁 lavamoat/
    • 📁 browserify/
      • 📁 beta/
        • 📄 policy.json +12 -0
      • 📁 experimental/
        • 📄 policy.json +12 -0
      • 📁 flask/
        • 📄 policy.json +12 -0
      • 📁 main/
        • 📄 policy.json +12 -0
    • 📁 webpack/
      • 📄 policy.json +12 -0

@metamaskbot
Copy link
Collaborator

📊 Page Load Benchmark Results

Current Commit: 8d19837 | Date: 10/16/2025

📄 Localhost MetaMask Test Dapp

Samples: 100

Summary

  • pageLoadTime-> current mean value: 1.05s (±75ms) 🟡 | historical mean value: 1.05s ⬆️ (historical data)
  • domContentLoaded-> current mean value: 746ms (±87ms) 🟢 | historical mean value: 735ms ⬆️ (historical data)
  • firstContentfulPaint-> current mean value: 83ms (±43ms) 🟢 | historical mean value: 78ms ⬆️ (historical data)
📈 Detailed Results
Metric Mean Std Dev Min Max P95 P99
pageLoadTime 1.05s 75ms 1.01s 1.36s 1.28s 1.36s
domContentLoaded 746ms 87ms 706ms 1.31s 961ms 1.31s
firstPaint 83ms 43ms 64ms 508ms 88ms 508ms
firstContentfulPaint 83ms 43ms 64ms 508ms 88ms 508ms
largestContentfulPaint 0ms 0ms 0ms 0ms 0ms 0ms

Results generated automatically by MetaMask CI

@metamaskbot
Copy link
Collaborator

Builds ready [8d19837]
UI Startup Metrics (1240 ± 78 ms)
PlatformBuildTypePageMetricMean (ms)Min (ms)Max (ms)Std Dev (ms)P 75 (ms)P 95 (ms)
ChromeBrowserifyHomeuiStartup1240111516087812721376
load106496112886710851192
domContentLoaded105695612746710801185
domInteractive18137591743
firstPaint72491128941410591194
backgroundConnect25223737415253272
firstReactRender261798102742
getState16595111830
initialActions40335517
loadScripts812705100966834943
setupStore1063541018
WebpackHomeuiStartup843718112667861957
load63558696669642783
domContentLoaded62858394667636777
domInteractive161169101443
firstPaint18953972186191613
backgroundConnect21103662534
firstReactRender27165283238
getState932131114
initialActions3010247
loadScripts62558193565634766
setupStore1061631214
FirefoxBrowserifyHomeuiStartup1421122918339914751581
load1213105514637612711347
domContentLoaded1213105514637612711347
domInteractive1103530249112251
firstPaintNaNNaNNaNNaNNaNNaN
backgroundConnect33217293754
firstReactRender24214432531
getState84394814
initialActions6118018312
loadScripts1191103414387412491321
setupStore126113131032
WebpackHomeuiStartup15531404199211515841827
load1329119915917813891463
domContentLoaded1328119915917813891463
domInteractive96313385498163
firstPaintNaNNaNNaNNaNNaNNaN
backgroundConnect3721136204084
firstReactRender33267883442
getState1049011927
initialActions6212716324
loadScripts1305117815637513561447
setupStore136137181051
Bundle size diffs [🚨 Warning! Bundle size has increased!]
  • background: 25.24 KiB (0.56%)
  • ui: -1 Bytes (0%)
  • common: 2.31 KiB (0.03%)

Copy link
Contributor

@davidmurdoch davidmurdoch left a comment

Choose a reason for hiding this comment

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

left a comment about the cursor review you should check out.,

if (balance) {
state.accountsByChainId[chainId][address].balance = toHex(balance);
state.accountsByChainId[chainId][lowercaseAddress].balance =
toHex(balance);
Copy link
Contributor

Choose a reason for hiding this comment

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

is this something you need to fix?

this.controllerMessenger.call('BackendWebSocketService:connect');
} else {
this.controllerMessenger.call('BackendWebSocketService:disconnect');
}
Copy link
Contributor

Choose a reason for hiding this comment

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

this seems fine

@Kriys94
Copy link
Contributor Author

Kriys94 commented Oct 16, 2025

left a comment about the cursor review you should check out.,
"is this something you need to fix?"
=> Yes because the AccountsTrackerController works with lowercase in extension and checksum in the core package (used in mobile). I decided to push for checksum address in the TokenBalancesController, as such, in the extension version of AccountTracker I need to enforce lowercase to work. I triple checked that and @bergarces has confirmed my statement

@metamaskbot
Copy link
Collaborator

✨ Files requiring CODEOWNER review ✨

🧩 @MetaMask/extension-devs (5 files, +60 -0)
  • 📁 lavamoat/
    • 📁 browserify/
      • 📁 beta/
        • 📄 policy.json +12 -0
      • 📁 experimental/
        • 📄 policy.json +12 -0
      • 📁 flask/
        • 📄 policy.json +12 -0
      • 📁 main/
        • 📄 policy.json +12 -0
    • 📁 webpack/
      • 📄 policy.json +12 -0

📜 @MetaMask/policy-reviewers (5 files, +60 -0)
  • 📁 lavamoat/
    • 📁 browserify/
      • 📁 beta/
        • 📄 policy.json +12 -0
      • 📁 experimental/
        • 📄 policy.json +12 -0
      • 📁 flask/
        • 📄 policy.json +12 -0
      • 📁 main/
        • 📄 policy.json +12 -0
    • 📁 webpack/
      • 📄 policy.json +12 -0

Tip

Follow the policy review process outlined in the LavaMoat Policy Review Process doc before expecting an approval from Policy Reviewers.


🔗 @MetaMask/supply-chain (5 files, +60 -0)
  • 📁 lavamoat/
    • 📁 browserify/
      • 📁 beta/
        • 📄 policy.json +12 -0
      • 📁 experimental/
        • 📄 policy.json +12 -0
      • 📁 flask/
        • 📄 policy.json +12 -0
      • 📁 main/
        • 📄 policy.json +12 -0
    • 📁 webpack/
      • 📄 policy.json +12 -0

@metamaskbot
Copy link
Collaborator

📊 Page Load Benchmark Results

Current Commit: c66db6b | Date: 10/16/2025

📄 Localhost MetaMask Test Dapp

Samples: 100

Summary

  • pageLoadTime-> current mean value: 1.04s (±70ms) 🟡 | historical mean value: 1.05s ⬇️ (historical data)
  • domContentLoaded-> current mean value: 726ms (±67ms) 🟢 | historical mean value: 738ms ⬇️ (historical data)
  • firstContentfulPaint-> current mean value: 75ms (±11ms) 🟢 | historical mean value: 78ms ⬇️ (historical data)
📈 Detailed Results
Metric Mean Std Dev Min Max P95 P99
pageLoadTime 1.04s 70ms 1.00s 1.30s 1.26s 1.30s
domContentLoaded 726ms 67ms 692ms 993ms 927ms 993ms
firstPaint 75ms 11ms 56ms 160ms 88ms 160ms
firstContentfulPaint 75ms 11ms 56ms 160ms 88ms 160ms
largestContentfulPaint 0ms 0ms 0ms 0ms 0ms 0ms

Results generated automatically by MetaMask CI

@metamaskbot
Copy link
Collaborator

Builds ready [c66db6b]
UI Startup Metrics (1267 ± 66 ms)
PlatformBuildTypePageMetricMean (ms)Min (ms)Max (ms)Std Dev (ms)P 75 (ms)P 95 (ms)
ChromeBrowserifyHomeuiStartup1267113814476613041386
load108698012385811161181
domContentLoaded107997112335811111177
domInteractive18135171740
firstPaint654120121943110991167
backgroundConnect25724328910261280
firstReactRender28196283347
getState17690102034
initialActions60669613
loadScripts82972098156860922
setupStore1063041218
WebpackHomeuiStartup806697106161824913
load61256986961619766
domContentLoaded60456385960613759
domInteractive15115581335
firstPaint20351740190192626
backgroundConnect2094272535
firstReactRender25163963032
getState931631113
initialActions3011247
loadScripts60156184958611749
setupStore951421112
FirefoxBrowserifyHomeuiStartup14321230191112415031697
load1201106014868412681359
domContentLoaded1201105914868412681359
domInteractive1003328248102228
firstPaintNaNNaNNaNNaNNaNNaN
backgroundConnect332099113851
firstReactRender31265663249
getState11414017936
initialActions7120221414
loadScripts1180104514608212471339
setupStore147196211053
WebpackHomeuiStartup15941403215011716231823
load1366123217108914051584
domContentLoaded1365123217098914041584
domInteractive1013136353103210
firstPaintNaNNaNNaNNaNNaNNaN
backgroundConnect3921125174469
firstReactRender302281123172
getState12415820944
initialActions51749314
loadScripts1341121516898513781540
setupStore136190211048
Bundle size diffs [🚨 Warning! Bundle size has increased!]
  • background: 25.24 KiB (0.56%)
  • ui: 5 Bytes (0%)
  • common: 2.31 KiB (0.03%)

@cdivitotawela
Copy link

For @MetaMask/policy-reviewers, apparently this PR requires approval from policy reviewers again. Both packages are internal metamask packages and added permission are required for the functionality. Policy changes looks good to me.

Copy link

@cdivitotawela cdivitotawela left a comment

Choose a reason for hiding this comment

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

Added packages are internal metamask packages and added permission are required for the functionality. Policy changes looks good to me.

@github-project-automation github-project-automation bot moved this from Needs dev review to Review finalised - Ready to be merged in PR review queue Oct 16, 2025
@Kriys94 Kriys94 added this pull request to the merge queue Oct 16, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Oct 16, 2025
@Kriys94 Kriys94 added this pull request to the merge queue Oct 16, 2025
Merged via the queue into main with commit f898063 Oct 16, 2025
170 checks passed
@Kriys94 Kriys94 deleted the feature/core-backend branch October 16, 2025 23:54
@github-project-automation github-project-automation bot moved this from Review finalised - Ready to be merged to Merged, Closed or Archived in PR review queue Oct 16, 2025
@github-actions github-actions bot locked and limited conversation to collaborators Oct 16, 2025
@metamaskbot metamaskbot added the release-13.6.0 Issue or pull request that will be included in release 13.6.0 label Oct 16, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

release-13.6.0 Issue or pull request that will be included in release 13.6.0 size-L team-assets team-extension-platform Extension Platform team

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

7 participants