Skip to content

feat(keyring-controller): log mutex and atomic operation timings - #11267

Draft
ccharly wants to merge 3 commits into
cc/feat/keyring-controller-vault-transactions-atomicfrom
cc/feat/keyring-controller-lock-timing
Draft

ccharly wants to merge 3 commits into
cc/feat/keyring-controller-vault-transactions-atomicfrom
cc/feat/keyring-controller-lock-timing

Conversation

@ccharly

@ccharly ccharly commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Stacked on #11241.

  • Follow the account-tree-controller project/module logger pattern.
  • Log controller and vault mutex request, acquisition, release, and completion with correlation IDs and operation labels.
  • Compute monotonic waitMs, holdMs, totalMs, and success, including persistence and rollback in locked timing.
  • Time atomic keyring operations outside the controller mutex separately from atomicUpdate commit windows. Keyring-internal locks are not observable here.
  • Omit operation arguments, results, and errors to avoid exposing secrets.
  • Enable using DEBUG=metamask:keyring-controller*.

Validation

  • All 447 package tests pass, including coverage thresholds (99.33% lines, 100% functions).
  • Package build, targeted Oxlint, formatting, and repository-wide changelog validation pass.
  • Broader development type-check reports existing errors in json-rpc-engine tests and the keyring test wordlist import.

Note

Low Risk
Observability-only refactor around existing mutex and atomic dispatch paths; locking semantics and secret handling are unchanged aside from new debug logs.

Overview
Adds opt-in lock timing diagnostics for @metamask/keyring-controller via DEBUG=metamask:keyring-controller*, without changing mutex behavior.

Mutex handling moves into a dedicated withLock helper that logs correlated Lock requested / Lock acquired / Lock released / Locked operation finished events for the controller and vault mutexes, with monotonic waitMs, holdMs, totalMs, and success. KeyringController now passes operation name labels (e.g. withKeyring, atomicUpdate, submitPassword) into every locked path so logs are attributable.

Atomic keyring work gets separate start/finish logs for the full operation run outside the controller lock, while atomicUpdate still shows up only as short controller-side commit windows. Logs deliberately exclude arguments, results, and error text.

Reviewed by Cursor Bugbot for commit e4a7bcb. Bugbot is set up for automated code reviews on this repo. Configure here.

@ccharly
ccharly requested review from a team as code owners November 3, 2026 14:47
@ccharly
ccharly marked this pull request as draft November 3, 2026 14:48

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant