Skip to content

fix: emit backup and sync trace only when mutations occur#9343

Open
mathieuartu wants to merge 6 commits into
mainfrom
fix/backup-sync-spans
Open

fix: emit backup and sync trace only when mutations occur#9343
mathieuartu wants to merge 6 commits into
mainfrom
fix/backup-sync-spans

Conversation

@mathieuartu

@mathieuartu mathieuartu commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Explanation

References

Related to: https://consensyssoftware.atlassian.net/browse/MUL-1965

Checklist

  • I've updated the test suite for new or updated code as appropriate
  • I've updated documentation (JSDoc, Markdown, etc.) for new or updated code as appropriate
  • I've communicated my changes to consumers by updating changelogs for packages I've changed
  • I've introduced breaking changes in this PR and have prepared draft pull requests for clients and consumer packages to resolve them

Note

Low Risk
Analytics/tracing behavior change in backup-and-sync only; sync logic is instrumented but not redesigned, with broad test coverage.

Overview
The Multichain Account Syncing - Full trace (TraceName.AccountSyncFull) is no longer wrapped around every full backup-and-sync run. Sync work runs untraced; a backdated span is emitted afterward only when the run recorded a durable change.

A new SyncMutationTracker on BackupAndSyncContext records remote writes (user storage pushes) and local writes (metadata/group/legacy updates). Sync helpers call setRemoteWrite / setLocalWrite when they actually persist. On per-wallet rollback, the local-write flag is restored with the state snapshot so reverted local edits do not count as mutations; remote writes still count.

Trace emission is best-effort (failures are logged, sync still completes and clears in-progress state). Tests cover no-op runs, local vs remote mutations, rollback, and failures after partial durable work.

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

@mathieuartu mathieuartu self-assigned this Jul 1, 2026
@mathieuartu mathieuartu requested review from a team as code owners July 1, 2026 14:20
sirtimid added a commit that referenced this pull request Jul 1, 2026
Follow-up to the `mm daemon list` review:

- Distinguish `ECONNRESET` (connection dropped mid-request, likely a
  daemon crash) from a stopped daemon, rather than telling the user to
  `mm daemon start` when one is already running.
- Name `MM_DATA_DIR` (the user-facing override) instead of the internal
  `MM_DAEMON_DATA_DIR` in the permission-denied hint.
- Extract a shared `formatJsonRpcError` helper and move `isStringArray`
  into `daemon/utils`; `daemon call` and `daemon list` now both use them.
- Parse argv in `daemon list` so unknown flags are rejected (matching
  `daemon call`).
- Fix the `daemon call` action example to a wired controller
  (`KeyringController:getState`).
- Point the connection-error changelog entry at #9339 (was #9343).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
sirtimid added a commit that referenced this pull request Jul 1, 2026
Follow-up to the `mm daemon list` review:

- Distinguish `ECONNRESET` (connection dropped mid-request, likely a
  daemon crash) from a stopped daemon, rather than telling the user to
  `mm daemon start` when one is already running.
- Name `MM_DATA_DIR` (the user-facing override) instead of the internal
  `MM_DAEMON_DATA_DIR` in the permission-denied hint.
- Extract a shared `formatJsonRpcError` helper and move `isStringArray`
  into `daemon/utils`; `daemon call` and `daemon list` now both use them.
- Parse argv in `daemon list` so unknown flags are rejected (matching
  `daemon call`).
- Fix the `daemon call` action example to a wired controller
  (`KeyringController:getState`).
- Point the connection-error changelog entry at #9339 (was #9343).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
sirtimid added a commit that referenced this pull request Jul 1, 2026
Follow-up to the `mm daemon list` review:

- Distinguish `ECONNRESET` (connection dropped mid-request, likely a
  daemon crash) from a stopped daemon, rather than telling the user to
  `mm daemon start` when one is already running.
- Name `MM_DATA_DIR` (the user-facing override) instead of the internal
  `MM_DAEMON_DATA_DIR` in the permission-denied hint.
- Extract a shared `formatJsonRpcError` helper and move `isStringArray`
  into `daemon/utils`; `daemon call` and `daemon list` now both use them.
- Parse argv in `daemon list` so unknown flags are rejected (matching
  `daemon call`).
- Fix the `daemon call` action example to a wired controller
  (`KeyringController:getState`).
- Point the connection-error changelog entry at #9339 (was #9343).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
sirtimid added a commit that referenced this pull request Jul 1, 2026
Follow-up to the `mm daemon list` review:

- Distinguish `ECONNRESET` (connection dropped mid-request, likely a
  daemon crash) from a stopped daemon, rather than telling the user to
  `mm daemon start` when one is already running.
- Name `MM_DATA_DIR` (the user-facing override) instead of the internal
  `MM_DAEMON_DATA_DIR` in the permission-denied hint.
- Extract a shared `formatJsonRpcError` helper and move `isStringArray`
  into `daemon/utils`; `daemon call` and `daemon list` now both use them.
- Parse argv in `daemon list` so unknown flags are rejected (matching
  `daemon call`).
- Fix the `daemon call` action example to a wired controller
  (`KeyringController:getState`).
- Point the connection-error changelog entry at #9339 (was #9343).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit d55336f. Configure here.

Comment thread packages/account-tree-controller/src/backup-and-sync/service/index.ts Outdated
@mathieuartu

Copy link
Copy Markdown
Contributor Author

@metamaskbot publish-preview

@mathieuartu

Copy link
Copy Markdown
Contributor Author

@metamaskbot publish-preview

@github-actions

github-actions Bot commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

Preview builds have been published. Learn how to use preview builds in other projects.

Expand for full list of packages and versions.
@metamask-previews/account-tree-controller@7.5.3-preview-ef063ff2d
@metamask-previews/accounts-controller@39.0.4-preview-ef063ff2d
@metamask-previews/address-book-controller@7.1.2-preview-ef063ff2d
@metamask-previews/ai-controllers@0.7.0-preview-ef063ff2d
@metamask-previews/analytics-controller@1.2.1-preview-ef063ff2d
@metamask-previews/analytics-data-regulation-controller@0.0.0-preview-ef063ff2d
@metamask-previews/announcement-controller@8.1.0-preview-ef063ff2d
@metamask-previews/app-metadata-controller@2.0.1-preview-ef063ff2d
@metamask-previews/approval-controller@9.0.2-preview-ef063ff2d
@metamask-previews/assets-controller@10.0.1-preview-ef063ff2d
@metamask-previews/assets-controllers@109.3.0-preview-ef063ff2d
@metamask-previews/authenticated-user-storage@3.0.0-preview-ef063ff2d
@metamask-previews/base-controller@9.1.0-preview-ef063ff2d
@metamask-previews/base-data-service@0.1.3-preview-ef063ff2d
@metamask-previews/bitcoin-regtest-up@1.0.0-preview-ef063ff2d
@metamask-previews/bridge-controller@77.3.2-preview-ef063ff2d
@metamask-previews/bridge-status-controller@74.0.2-preview-ef063ff2d
@metamask-previews/build-utils@3.0.4-preview-ef063ff2d
@metamask-previews/chain-agnostic-permission@1.6.2-preview-ef063ff2d
@metamask-previews/chomp-api-service@3.1.0-preview-ef063ff2d
@metamask-previews/claims-controller@0.5.3-preview-ef063ff2d
@metamask-previews/client-controller@1.0.1-preview-ef063ff2d
@metamask-previews/client-utils@0.0.0-preview-ef063ff2d
@metamask-previews/compliance-controller@2.1.0-preview-ef063ff2d
@metamask-previews/composable-controller@12.0.1-preview-ef063ff2d
@metamask-previews/config-registry-controller@0.4.1-preview-ef063ff2d
@metamask-previews/connectivity-controller@0.2.0-preview-ef063ff2d
@metamask-previews/controller-utils@12.3.0-preview-ef063ff2d
@metamask-previews/core-backend@6.5.0-preview-ef063ff2d
@metamask-previews/delegation-controller@3.0.2-preview-ef063ff2d
@metamask-previews/earn-controller@12.2.2-preview-ef063ff2d
@metamask-previews/eip-5792-middleware@3.0.4-preview-ef063ff2d
@metamask-previews/eip-7702-internal-rpc-middleware@0.1.1-preview-ef063ff2d
@metamask-previews/eip1193-permission-middleware@2.0.1-preview-ef063ff2d
@metamask-previews/ens-controller@19.1.5-preview-ef063ff2d
@metamask-previews/eth-block-tracker@15.0.1-preview-ef063ff2d
@metamask-previews/eth-json-rpc-middleware@23.1.3-preview-ef063ff2d
@metamask-previews/eth-json-rpc-provider@6.0.1-preview-ef063ff2d
@metamask-previews/foundryup@1.0.1-preview-ef063ff2d
@metamask-previews/gas-fee-controller@26.2.4-preview-ef063ff2d
@metamask-previews/gator-permissions-controller@4.2.2-preview-ef063ff2d
@metamask-previews/geolocation-controller@0.1.3-preview-ef063ff2d
@metamask-previews/java-tron-up@1.0.0-preview-ef063ff2d
@metamask-previews/json-rpc-engine@10.5.0-preview-ef063ff2d
@metamask-previews/json-rpc-middleware-stream@8.0.8-preview-ef063ff2d
@metamask-previews/keyring-controller@27.1.0-preview-ef063ff2d
@metamask-previews/local-node-utils@1.0.0-preview-ef063ff2d
@metamask-previews/logging-controller@8.0.2-preview-ef063ff2d
@metamask-previews/message-manager@14.1.2-preview-ef063ff2d
@metamask-previews/messenger@1.2.0-preview-ef063ff2d
@metamask-previews/messenger-cli@0.2.0-preview-ef063ff2d
@metamask-previews/money-account-balance-service@2.1.2-preview-ef063ff2d
@metamask-previews/money-account-controller@0.3.3-preview-ef063ff2d
@metamask-previews/money-account-upgrade-controller@2.2.1-preview-ef063ff2d
@metamask-previews/multichain-account-service@11.1.0-preview-ef063ff2d
@metamask-previews/multichain-api-middleware@4.0.0-preview-ef063ff2d
@metamask-previews/multichain-network-controller@3.2.1-preview-ef063ff2d
@metamask-previews/multichain-transactions-controller@7.1.1-preview-ef063ff2d
@metamask-previews/name-controller@9.1.2-preview-ef063ff2d
@metamask-previews/network-controller@34.0.0-preview-ef063ff2d
@metamask-previews/network-enablement-controller@5.4.1-preview-ef063ff2d
@metamask-previews/notification-services-controller@24.3.0-preview-ef063ff2d
@metamask-previews/passkey-controller@2.0.1-preview-ef063ff2d
@metamask-previews/permission-controller@13.1.1-preview-ef063ff2d
@metamask-previews/permission-log-controller@5.1.0-preview-ef063ff2d
@metamask-previews/perps-controller@9.2.0-preview-ef063ff2d
@metamask-previews/phishing-controller@17.2.0-preview-ef063ff2d
@metamask-previews/platform-api-docs@0.0.0-preview-ef063ff2d
@metamask-previews/polling-controller@16.0.8-preview-ef063ff2d
@metamask-previews/preferences-controller@23.1.0-preview-ef063ff2d
@metamask-previews/profile-metrics-controller@4.0.1-preview-ef063ff2d
@metamask-previews/profile-sync-controller@28.2.0-preview-ef063ff2d
@metamask-previews/ramps-controller@15.0.0-preview-ef063ff2d
@metamask-previews/rate-limit-controller@7.0.1-preview-ef063ff2d
@metamask-previews/react-data-query@0.2.1-preview-ef063ff2d
@metamask-previews/remote-feature-flag-controller@4.2.2-preview-ef063ff2d
@metamask-previews/sample-controllers@5.0.3-preview-ef063ff2d
@metamask-previews/seedless-onboarding-controller@10.0.3-preview-ef063ff2d
@metamask-previews/selected-network-controller@26.1.5-preview-ef063ff2d
@metamask-previews/shield-controller@5.1.2-preview-ef063ff2d
@metamask-previews/signature-controller@39.2.7-preview-ef063ff2d
@metamask-previews/smart-transactions-controller@24.2.4-preview-ef063ff2d
@metamask-previews/snap-account-service@1.0.0-preview-ef063ff2d
@metamask-previews/social-controllers@2.3.1-preview-ef063ff2d
@metamask-previews/solana-test-validator-up@1.0.0-preview-ef063ff2d
@metamask-previews/stellar-quickstart-up@0.0.0-preview-ef063ff2d
@metamask-previews/storage-service@1.0.2-preview-ef063ff2d
@metamask-previews/subscription-controller@6.2.0-preview-ef063ff2d
@metamask-previews/transaction-controller@68.2.2-preview-ef063ff2d
@metamask-previews/transaction-pay-controller@23.17.4-preview-ef063ff2d
@metamask-previews/user-operation-controller@41.2.6-preview-ef063ff2d
@metamask-previews/wallet@6.0.0-preview-ef063ff2d
@metamask-previews/wallet-cli@0.0.0-preview-ef063ff2d

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant