Skip to content

fix(auth): add mutex-protected atomic metadata updates#328

Merged
CharlVS merged 1 commit intodevfrom
fix/metadata-race
Mar 21, 2026
Merged

fix(auth): add mutex-protected atomic metadata updates#328
CharlVS merged 1 commit intodevfrom
fix/metadata-race

Conversation

@CharlVS
Copy link
Copy Markdown
Collaborator

@CharlVS CharlVS commented Mar 21, 2026

Summary

  • Adds a dedicated _metadataMutex to KdfAuthService that serialises all read-modify-write cycles on user metadata, preventing concurrent coin activations from overwriting each other's state.
  • Introduces updateActiveUserMetadataKey on IAuthService / KomodoDefiAuth for atomic single-key transforms, and migrates setOrRemoveActiveUserKeyValue to use it internally.
  • Updates bundled coins config to point to master branch (aceacfb).

Test plan

  • Verify concurrent coin activations no longer lose metadata (e.g. enabled coins list stays consistent)
  • Confirm setOrRemoveActiveUserKeyValue still works correctly for setting/removing individual keys
  • Check that updateActiveUserKeyValue correctly applies transforms and persists results
  • Validate build config fetches coins from master branch successfully

Add a dedicated metadata mutex to serialise read-modify-write cycles
on user metadata, preventing concurrent coin activations from
overwriting each other's state. Introduces updateActiveUserMetadataKey
for atomic single-key transforms and migrates setOrRemoveActiveUserKeyValue
to use it.

Also updates bundled coins config to master branch (aceacfb).
@chatgpt-codex-connector
Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, you can upgrade your account or add credits to your account and enable them for code reviews in your settings.

CharlVS added a commit to GLEECBTC/gleec-wallet that referenced this pull request Mar 21, 2026
Points to GLEECBTC/komodo-defi-sdk-flutter#328 which adds
mutex-protected atomic metadata updates to prevent concurrent
coin activations from overwriting each other's state.
@CharlVS CharlVS merged commit 9532870 into dev Mar 21, 2026
2 of 4 checks passed
@CharlVS CharlVS deleted the fix/metadata-race branch March 21, 2026 17:34
@github-actions
Copy link
Copy Markdown
Contributor

Visit the preview URL for this PR (updated for commit fbce69f):

https://komodo-playground--pr328-fix-metadata-race-w2lazcx9.web.app

(expires Sat, 28 Mar 2026 17:37:52 GMT)

🔥 via Firebase Hosting GitHub Action 🌎

Sign: 2bfedd77fdea45b25ba7c784416e81f177aa5c47

CharlVS added a commit that referenced this pull request Mar 23, 2026
The IAuthService interface gained updateActiveUserMetadataKey in #328
but the _FakeAuthService in the Trezor auth tests was not updated,
causing a compilation error.
CharlVS added a commit that referenced this pull request Mar 23, 2026
…ce (#330)

The IAuthService interface gained updateActiveUserMetadataKey in #328
but the _FakeAuthService in the Trezor auth tests was not updated,
causing a compilation error.
CharlVS added a commit to GLEECBTC/gleec-wallet that referenced this pull request Mar 23, 2026
…3454)

* chore(sdk): roll submodule for metadata race fix

Points to GLEECBTC/komodo-defi-sdk-flutter#328 which adds
mutex-protected atomic metadata updates to prevent concurrent
coin activations from overwriting each other's state.

* fix(coins): use atomic metadata updates for coin activation

Batch-write all asset IDs to wallet metadata in a single call before
launching parallel activations, then pass addToWalletMetadata: false
to avoid N concurrent read-modify-write cycles that caused
last-write-wins data loss.

Migrate addActivatedCoins/removeActivatedCoins to use the new
updateActiveUserKeyValue API for atomic single-key transforms.

* chore(sdk): roll submodule to dev (9532870)

Includes fix(auth): add mutex-protected atomic metadata updates (#328).

* chore(sdk): advance submodule to 317719d for WASM valueOrNull fix

The merge from dev picked the fix/metadata-race side's SDK pointer
(9532870, #328 only) instead of dev's pointer (317719d) which also
includes #329 — the reified generics fix for _traverseJson that
prevents valueOrNull<List<String>> from silently returning null
in WASM/minified release builds.

* chore(sdk): bump submodule for trezor test compilation fix

Points to fix/trezor-test-missing-method (ea99ec6) which adds the
missing updateActiveUserMetadataKey stub to _FakeAuthService in
trezor_auth_service_test.dart.

* chore(sdk): roll submodule to dev (c70beed)

Includes #328 (atomic metadata updates), #329 (reified generics for
WASM), and #330 (trezor test compilation fix).

* ci: trigger CI rebuild

* chore(sdk): bump submodule to dev after bundled coins commit merge

Points sdk at 869dd00 (komodo-defi-sdk-flutter dev), including PR #331.
CharlVS added a commit that referenced this pull request Apr 1, 2026
Add a dedicated metadata mutex to serialise read-modify-write cycles
on user metadata, preventing concurrent coin activations from
overwriting each other's state. Introduces updateActiveUserMetadataKey
for atomic single-key transforms and migrates setOrRemoveActiveUserKeyValue
to use it.

Also updates bundled coins config to master branch (aceacfb).
CharlVS added a commit that referenced this pull request Apr 1, 2026
…ce (#330)

The IAuthService interface gained updateActiveUserMetadataKey in #328
but the _FakeAuthService in the Trezor auth tests was not updated,
causing a compilation error.
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