Skip to content

Conversation

@bergarces
Copy link
Contributor

@bergarces bergarces commented Oct 13, 2025

Description

This PR concludes the migration to AccountsTrackerController from core. This is necessary in order to benefit from performance changes added and planned to the core controller.

Open in GitHub Codespaces

Changelog

CHANGELOG entry: null

Related issues

Fixes: https://consensyssoftware.atlassian.net/browse/ASSETS-1368

Manual testing steps

Screenshots/Recordings

Before

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.

Note

Replaces the local AccountTrackerController with the core one, removes legacy tracker/polling and gas-limit state, and updates state shape, selectors, metrics, tests, and dependencies accordingly.

  • Core/Controllers:
    • Replace local AccountTrackerController with @metamask/assets-controllers version; update init, messengers, allowed actions/events, and wiring.
    • Remove legacy files (account-tracker-controller*, batch-utils*, constants/contracts.ts, types) and related listeners/APIs (e.g., balance-update on tx, account syncing).
    • Drop accounts and currentBlockGasLimit* from background/UI state; rely on accountsByChainId only; update sentry state and types.
    • Remove account-tracker polling APIs/hook; stop exposing start/stop polling from background.
    • Bump @metamask/assets-controllers to ^86.0.0; update LavaMoat policies.
    • Preferences: add isMultiAccountBalancesEnabled mirroring useMultiAccountBalanceChecker.
  • MetaMaskController:
    • Remove tracker syncing/clearing and tx-balance update; use checksummed addresses in getBalance and metrics.
  • Transactions/Init:
    • Simplify listeners; stop updating balances on tx events.
  • UI/Selectors & Send Flow:
    • Normalize accountsByChainId address handling (lowercasing in selectors); remove getBlockGasLimit usage; adjust gas estimate logic.
    • Fix token-search null guard; update tests/fixtures to checksummed addresses.
  • Metrics/Telemetry:
    • Compute number_of_accounts from accountsByChainId; update masked/removed fields.
  • Tests/Fixtures:
    • Update mocks to checksummed addresses; remove obsolete expectations/delays; align with new state shape.

Written by Cursor Bugbot for commit 3cfb04e. This will update automatically on new commits. Configure here.

@github-actions
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.

@metamaskbot
Copy link
Collaborator

metamaskbot commented Oct 13, 2025

✨ Files requiring CODEOWNER review ✨

@MetaMask/confirmations (1 files, +0 -15)
  • 📁 app/
    • 📁 scripts/
      • 📁 controller-init/
        • 📁 confirmations/
          • 📄 transaction-controller-init.ts +0 -15

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

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

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, +6 -5)
  • 📁 lavamoat/
    • 📁 browserify/
      • 📁 beta/
        • 📄 policy.json +1 -1
      • 📁 experimental/
        • 📄 policy.json +1 -1
      • 📁 flask/
        • 📄 policy.json +1 -1
      • 📁 main/
        • 📄 policy.json +1 -1
    • 📁 webpack/
      • 📄 policy.json +2 -1

👨‍🔧 @MetaMask/wallet-integrations (2 files, +6 -16)
  • 📁 app/
    • 📁 scripts/
      • 📁 lib/
        • 📁 rpc-method-middleware/
          • 📁 handlers/
            • 📄 request-accounts.test.ts +0 -14
            • 📄 request-accounts.ts +6 -2

useExternalServices: true,
// from core PreferencesController
isMultiAccountBalancesEnabled: true,
useMultiAccountBalanceChecker: true,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Putting them together as it'll be easier to remove one when we eventually migrate to the core PreferencesController. For now, and considering this PR is already big enough, we are keeping both.

*/
export function getKeyringControllerMessenger(
messenger: Messenger<AllowedActions, AllowedEvents>,
messenger: Messenger<never, never>,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

It was using the wrong types from a different controller. KeyringController does not require any AllowedActions or AllowedEvents

networkClientId,
);
},
includeStakedAssets: false,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not part of this PR to include staked assets in the assets list. When we want to enable them, we can do so.

setUseMultiAccountBalanceChecker(val: boolean): void {
this.update((state) => {
state.useMultiAccountBalanceChecker = val;
state.isMultiAccountBalancesEnabled = val;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Making sure isMultiAccountBalancesEnabled gets updated as well. Before this, it was always kept as true and not being used at all.

@bergarces
Copy link
Contributor Author

@MetaMask/policy-reviewers Changes related to the removal of single-call-balance-checker-abi from extension. It is now using the one installed under @metamask/assets-controllers.

@metamaskbot
Copy link
Collaborator

📊 Page Load Benchmark Results

Current Commit: f87fae0 | Date: 10/31/2025

📄 Localhost MetaMask Test Dapp

Samples: 100

Summary

  • pageLoadTime-> current mean value: 1.05s (±74ms) 🟡 | historical mean value: 1.04s ⬆️ (historical data)
  • domContentLoaded-> current mean value: 741ms (±85ms) 🟢 | historical mean value: 725ms ⬆️ (historical data)
  • firstContentfulPaint-> current mean value: 88ms (±126ms) 🟢 | historical mean value: 76ms ⬆️ (historical data)
📈 Detailed Results
Metric Mean Std Dev Min Max P95 P99
pageLoadTime 1.05s 74ms 1.02s 1.34s 1.30s 1.34s
domContentLoaded 741ms 85ms 702ms 1.28s 974ms 1.28s
firstPaint 88ms 126ms 60ms 1.34s 88ms 1.34s
firstContentfulPaint 88ms 126ms 60ms 1.34s 88ms 1.34s
largestContentfulPaint 0ms 0ms 0ms 0ms 0ms 0ms

Results generated automatically by MetaMask CI

@metamaskbot
Copy link
Collaborator

Builds ready [f87fae0]
UI Startup Metrics (1256 ± 87 ms)
PlatformBuildTypePageMetricMean (ms)Min (ms)Max (ms)Std Dev (ms)P 75 (ms)P 95 (ms)
ChromeBrowserifyStandard HomeuiStartup1256108714388713081423
load107893212377711311213
domContentLoaded107192712297611251206
domInteractive211468121857
firstPaint65978124043110891198
backgroundConnect2292162698233245
firstReactRender28185882945
getState20881112334
initialActions716111639
loadScripts84870199874903966
setupStore1062431015
numNetworkReqs1367821675
BrowserifyPower User HomeuiStartup20631762327638323673276
load1081920175823912991758
domContentLoaded1070913169622912951696
domInteractive311583235483
firstPaint6738217054719631705
backgroundConnect24021933627248336
firstReactRender27243433034
getState19116127131215271
initialActions725212552
loadScripts843699141521510791415
setupStore1081411114
numNetworkReqs15610131179230311
WebpackStandard HomeuiStartup8997661235909131159
load66260198877664897
domContentLoaded65359496071658880
domInteractive17126081538
firstPaint21159969189207634
backgroundConnect301393173282
firstReactRender301894103638
getState1373041520
initialActions41213510
loadScripts65059294669655868
setupStore1262441420
numNetworkReqs1467920874
WebpackPower User HomeuiStartup12601089172422014611724
load644557878110730878
domContentLoaded62354582995713829
domInteractive29121583638158
firstPaint31156874291568874
backgroundConnect721027291206272
firstReactRender25233222632
getState1359216720144167
initialActions31174417
loadScripts61954382093711820
setupStore1162461324
numNetworkReqs1499828464195284
FirefoxBrowserifyStandard HomeuiStartup15021267193512315671773
load1273108914949213391458
domContentLoaded1273108814949213391457
domInteractive1213439753134219
firstPaint------
backgroundConnect47271882652116
firstReactRender26214852739
getState843451117
initialActions616910415
loadScripts1244107014639113081429
setupStore156181181337
numNetworkReqs1366517763
BrowserifyPower User HomeuiStartup24742161326230926483262
load13901143176618715191766
domContentLoaded13891142176518715181765
domInteractive21184636179364636
firstPaint------
backgroundConnect992930174117301
firstReactRender39305274452
getState1254018335157183
initialActions2112115023211
loadScripts13531120173618514871736
setupStore4783588449358
numNetworkReqs1377033177199331
WebpackStandard HomeuiStartup15411357200514315821891
load13231154170111013461577
domContentLoaded13231154170111013451577
domInteractive953432541106173
firstPaint------
backgroundConnect46201412448108
firstReactRender302172132868
getState74475914
initialActions40265324
loadScripts1295113815879813221501
setupStore167161201269
numNetworkReqs1467318868
WebpackPower User HomeuiStartup24142142298927827472989
load14981243196522817171965
domContentLoaded14971243196422817161964
domInteractive18139567168383567
firstPaint------
backgroundConnect873424874126248
firstReactRender49311212554121
getState1329720131148201
initialActions8038101438
loadScripts14691223191922216881919
setupStore2461062621106
numNetworkReqs1306321564198215
Bundle size diffs [🚀 Bundle size reduced!]
  • background: -17.04 KiB (-0.37%)
  • ui: -345 Bytes (0%)
  • common: 385 Bytes (0%)

@metamaskbot
Copy link
Collaborator

📊 Page Load Benchmark Results

Current Commit: ba0182f | Date: 10/31/2025

📄 Localhost MetaMask Test Dapp

Samples: 100

Summary

  • pageLoadTime-> current mean value: 1.06s (±47ms) 🟡 | historical mean value: 1.04s ⬆️ (historical data)
  • domContentLoaded-> current mean value: 744ms (±62ms) 🟢 | historical mean value: 725ms ⬆️ (historical data)
  • firstContentfulPaint-> current mean value: 91ms (±129ms) 🟢 | historical mean value: 76ms ⬆️ (historical data)
📈 Detailed Results
Metric Mean Std Dev Min Max P95 P99
pageLoadTime 1.06s 47ms 1.03s 1.44s 1.10s 1.44s
domContentLoaded 744ms 62ms 720ms 1.31s 775ms 1.31s
firstPaint 91ms 129ms 64ms 1.37s 92ms 1.37s
firstContentfulPaint 91ms 129ms 64ms 1.37s 92ms 1.37s
largestContentfulPaint 0ms 0ms 0ms 0ms 0ms 0ms

Results generated automatically by MetaMask CI

@metamaskbot
Copy link
Collaborator

Builds ready [ba0182f]
UI Startup Metrics (1315 ± 105 ms)
PlatformBuildTypePageMetricMean (ms)Min (ms)Max (ms)Std Dev (ms)P 75 (ms)P 95 (ms)
ChromeBrowserifyStandard HomeuiStartup13151169175810513831501
load111795114529411811274
domContentLoaded110894414419511751265
domInteractive241498152262
firstPaint73181148145411381280
backgroundConnect23722132014241252
firstReactRender361991124451
getState2410100132742
initialActions818712826
loadScripts8797161187939481038
setupStore1172941222
numNetworkReqs1468021675
BrowserifyPower User HomeuiStartup20841836277534025732775
load1097951149319813931493
domContentLoaded1086944144319313821443
domInteractive281665175065
firstPaint72892148849510221488
backgroundConnect24422528615249286
firstReactRender27253432834
getState18114326728199267
initialActions825112651
loadScripts856726120918711091209
setupStore1492871228
numNetworkReqs15810132189303321
WebpackStandard HomeuiStartup834710115178855980
load60755192366615749
domContentLoaded59954690363606735
domInteractive16114571434
firstPaint19052904204169717
backgroundConnect261382132760
firstReactRender29178393337
getState1263131416
initialActions4112249
loadScripts59654489462604728
setupStore1162741319
numNetworkReqs1467820874
WebpackPower User HomeuiStartup13621189184224516841842
load67861091191761911
domContentLoaded65359680273723802
domInteractive231361164061
firstPaint336103776222609776
backgroundConnect701823478166234
firstReactRender26243422634
getState15211421523157215
initialActions30297329
loadScripts64959479169713791
setupStore14639102339
numNetworkReqs1479728268199282
FirefoxBrowserifyStandard HomeuiStartup14611255190013015371727
load1237106315229812981402
domContentLoaded1237106315229812971401
domInteractive1193431551134247
firstPaint------
backgroundConnect44251332050105
firstReactRender25214752637
getState84507717
initialActions6219119314
loadScripts1211104614939212731364
setupStore14889121236
numNetworkReqs1367017765
BrowserifyPower User HomeuiStartup24942179325234227483252
load13671219166214615491662
domContentLoaded13671219166214615481662
domInteractive20181505149420505
firstPaint------
backgroundConnect1123833992187339
firstReactRender40295594955
getState1208817621138176
initialActions12268171368
loadScripts13351188163114414991631
setupStore27569184569
numNetworkReqs1396832893223328
WebpackStandard HomeuiStartup15561390218716715502075
load13301197162410113511589
domContentLoaded13291197162410213511589
domInteractive983245749105155
firstPaint------
backgroundConnect44211672547110
firstReactRender302172132869
getState10420020820
initialActions41315413
loadScripts1302117616029113271507
setupStore187213311360
numNetworkReqs1467319769
WebpackPower User HomeuiStartup26692229387052632323870
load15151265196122417981961
domContentLoaded15141264196022417971960
domInteractive18752614166382614
firstPaint------
backgroundConnect1063031993144319
firstReactRender44335785257
getState1499124039178240
initialActions823481334
loadScripts14801245192221317681922
setupStore4371474162147
numNetworkReqs13564342104265342
Bundle size diffs [🚀 Bundle size reduced!]
  • background: -17.04 KiB (-0.37%)
  • ui: -345 Bytes (0%)
  • common: 385 Bytes (0%)

@metamaskbot
Copy link
Collaborator

📊 Page Load Benchmark Results

Current Commit: 3cfb04e | Date: 10/31/2025

📄 Localhost MetaMask Test Dapp

Samples: 100

Summary

  • pageLoadTime-> current mean value: 1.03s (±41ms) 🟡 | historical mean value: 1.04s ⬇️ (historical data)
  • domContentLoaded-> current mean value: 717ms (±38ms) 🟢 | historical mean value: 722ms ⬇️ (historical data)
  • firstContentfulPaint-> current mean value: 75ms (±11ms) 🟢 | historical mean value: 77ms ⬇️ (historical data)
📈 Detailed Results
Metric Mean Std Dev Min Max P95 P99
pageLoadTime 1.03s 41ms 1.00s 1.30s 1.06s 1.30s
domContentLoaded 717ms 38ms 695ms 976ms 754ms 976ms
firstPaint 75ms 11ms 60ms 172ms 84ms 172ms
firstContentfulPaint 75ms 11ms 60ms 172ms 84ms 172ms
largestContentfulPaint 0ms 0ms 0ms 0ms 0ms 0ms

Results generated automatically by MetaMask CI

@metamaskbot
Copy link
Collaborator

Builds ready [3cfb04e]
UI Startup Metrics (1258 ± 101 ms)
PlatformBuildTypePageMetricMean (ms)Min (ms)Max (ms)Std Dev (ms)P 75 (ms)P 95 (ms)
ChromeBrowserifyStandard HomeuiStartup12581097168410113071440
load107894113999211351240
domContentLoaded107293613899111291233
domInteractive211467121855
firstPaint643108128343210741218
backgroundConnect2292152577232240
firstReactRender30176483644
getState21862102446
initialActions61295715
loadScripts8497251159899011007
setupStore1062231120
numNetworkReqs1468121676
BrowserifyPower User HomeuiStartup20121743285433224312854
load1073920150021713511500
domContentLoaded1065913149421713371494
domInteractive281586214786
firstPaint84618914893599841489
backgroundConnect23622129618241296
firstReactRender26232922829
getState17916420915192209
initialActions11250151150
loadScripts839692125120611061251
setupStore1292741227
numNetworkReqs15610431186297311
WebpackStandard HomeuiStartup91376512551069401197
load679602100796678943
domContentLoaded67159497493672927
domInteractive16124571537
firstPaint21363981231186910
backgroundConnect3013158222977
firstReactRender29177093639
getState1373351521
initialActions40163513
loadScripts66759296490669916
setupStore1153551421
numNetworkReqs1468020873
WebpackPower User HomeuiStartup13451191176421416141764
load69061210281197511028
domContentLoaded66460191688732916
domInteractive271384253884
firstPaint40468818265617818
backgroundConnect60122637155263
firstReactRender26252812628
getState15011318317157183
initialActions31174217
loadScripts65959990584721905
setupStore86162816
numNetworkReqs14210027362199273
FirefoxBrowserifyStandard HomeuiStartup14401248182411414871665
load1223107214318212681381
domContentLoaded1223107214318212661381
domInteractive1143331447122224
firstPaint------
backgroundConnect402399134562
firstReactRender25214642533
getState74324714
initialActions41234314
loadScripts1199105714107912421349
setupStore147186201132
numNetworkReqs1366817865
BrowserifyPower User HomeuiStartup25502088339634028003396
load14351168193724517501937
domContentLoaded14341167193624517491936
domInteractive21790673184394673
firstPaint------
backgroundConnect13435534122192534
firstReactRender42326295162
getState1479220033171200
initialActions72225922
loadScripts13821143188224116211882
setupStore3161002746100
numNetworkReqs1366832076194320
WebpackStandard HomeuiStartup16201445202111416511883
load1382121516868614141573
domContentLoaded1382121516868614131572
domInteractive983217930113155
firstPaint------
backgroundConnect50261252256111
firstReactRender312382123170
getState944861016
initialActions7120421419
loadScripts1352119816037813851498
setupStore14667101334
numNetworkReqs1367017865
WebpackPower User HomeuiStartup25802104366445030793664
load14921247182420618041824
domContentLoaded14921247182420618031824
domInteractive18469601172330601
firstPaint------
backgroundConnect11233390113215390
firstReactRender41305995059
getState1499727246198272
initialActions13168192168
loadScripts14621216178219817531782
setupStore3091253041125
numNetworkReqs13967339100260339
Bundle size diffs [🚀 Bundle size reduced!]
  • background: -17.04 KiB (-0.37%)
  • ui: -345 Bytes (0%)
  • common: 385 Bytes (0%)

@bergarces bergarces changed the title feat: assets controllers package upgrade chore: AccountTrackerController migration Oct 31, 2025
Copy link
Contributor

@ccharly ccharly left a comment

Choose a reason for hiding this comment

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

LGTM for accounts files (assuming this is valid, but I'll let @seaona confirm that 😁)

Copy link
Member

@seaona seaona left a comment

Choose a reason for hiding this comment

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

Overall changes make sense. I added a couple of nits. Given this is a big PR with lots of code owners, it's not 100% blocking, but it would be good to have a follow-up PR addressing the changes, if this makes sense @bergarces

recipientAddress: DEFAULT_FIXTURE_ACCOUNT,
amount: '1',
});
await driver.waitForSelector('.transaction-status-label--confirmed');
Copy link
Member

Choose a reason for hiding this comment

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

small nit but we shouldn't include selectors in the spec files, rather move them in page objects. This helps maintainability and scalability of our e2e suite

amount: '1',
isSyncFlow: false,
});
await driver.waitForSelector('.transaction-status-label--confirmed');
Copy link
Member

Choose a reason for hiding this comment

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

same as above: no selectors in spec files

// Balance is 0 because aggregated balance has changed and doesn't display dev networks
// The method should be udpdated to use the new selector and we can then remove checkExpectedTokenBalanceIsDisplayed
await loginWithBalanceValidation(driver, undefined, undefined, '0');
await loginWithBalanceValidation(driver);
Copy link
Member

Choose a reason for hiding this comment

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

thanks for the comment, it makes sense to me

@bergarces bergarces added this pull request to the merge queue Oct 31, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Oct 31, 2025
@bergarces bergarces added this pull request to the merge queue Oct 31, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Oct 31, 2025
@bergarces bergarces added this pull request to the merge queue Oct 31, 2025
Merged via the queue into main with commit b1ccf26 Oct 31, 2025
487 of 494 checks passed
@bergarces bergarces deleted the account-tracker-controller-migration branch October 31, 2025 20:06
@github-actions github-actions bot locked and limited conversation to collaborators Oct 31, 2025
@metamaskbot metamaskbot added the release-13.9.0 Issue or pull request that will be included in release 13.9.0 label Oct 31, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

release-13.9.0 Issue or pull request that will be included in release 13.9.0 size-XL team-assets

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Assets - Import Token before the wallet is fully loaded, breaks the wallet with the errorcan't convert undefined to object

9 participants