Skip to content

fix(multichain-account-service): prevent spurious alignment logs + smaller map state updates#8136

Open
ccharly wants to merge 1 commit intomainfrom
cc/fix/align-accounts-logs
Open

fix(multichain-account-service): prevent spurious alignment logs + smaller map state updates#8136
ccharly wants to merge 1 commit intomainfrom
cc/fix/align-accounts-logs

Conversation

@ccharly
Copy link
Contributor

@ccharly ccharly commented Mar 6, 2026

Explanation

The current condition was ALWAYS logging the Found missing accounts for account provider... line, since all alignments always returns the full list of accounts (even existing ones).

To avoid triggering this, we now make a proper diff-set between the old accounts and new ones.

There's another benefit with doing this. Instead of clearing the entire state map, we now make smaller state update, which should be slightly faster when we have a tons of groups with a lot of accounts.

References

N/A

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

Medium Risk
Touches MultichainAccountGroup.alignAccounts state-mapping logic, including removing accounts when providers return fewer IDs, which could impact account visibility if the diffing is incorrect. Changes are scoped and covered by new unit tests, lowering the likelihood of regressions.

Overview
Improves MultichainAccountGroup.alignAccounts by diffing old vs new account IDs per provider instead of clearing and rebuilding all provider/account maps on every alignment. This prevents the “missing accounts” log from firing on no-op alignments and reduces state churn by only updating mappings when accounts were actually added/removed (and deleting mappings when a provider becomes disabled).

Adds tests to ensure alignment removes accounts that providers stop returning, and introduces AccountProviderWrapper alignment tests for enabled/disabled behavior. Updates Jest config to ignore src/tests helpers for coverage, and records the change/fix in the package changelog.

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

@ccharly ccharly force-pushed the cc/fix/align-accounts-logs branch from 5fe9be0 to db3a2cc Compare March 6, 2026 17:26
return { wrapper, innerProvider };
}

describe('AccountProviderWrapper', () => {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've added some more tests for the wrapper, since we skip the alignAccounts call from the wrapper entirely now in case it's disabled.

So, with this new file, we can actually get better coverage in a more "unit-tests-like way" for this class.

displayName,

// Exclude test helpers from coverage collection
coveragePathIgnorePatterns: ['.*/src/tests/.*'],
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Some of the mock providers are not covered/used anymore by our tests.

The src/tests/providers.ts file is pretty messy right now, and instead of removing/moving things around, I prefer to not have it in the coverage at all for the time being.

I do plan to make a small refactor around that to avoid the .prototype hacks we're using there.

@ccharly ccharly changed the title fix(multichain-account-service): prevent spurrious alignment logs + smaller map state updates fix(multichain-account-service): prevent spurious alignment logs + smaller map state updates Mar 6, 2026
@ccharly ccharly marked this pull request as ready for review March 6, 2026 17:29
@ccharly ccharly requested review from a team as code owners March 6, 2026 17:29
@ccharly ccharly force-pushed the cc/fix/align-accounts-logs branch from db3a2cc to 875cf51 Compare March 6, 2026 17:31
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