Skip to content

Conversation

ccharly
Copy link
Contributor

@ccharly ccharly commented Sep 9, 2025

Explanation

Wallet operations are not behind a mutex. This ensure that only one mutable operation can be executed at a time.

Also publish new event, so we know in which state a wallet is.

Note

A follow-up PR will be using those events to add a new status in the account-tree-controller.

Depends on this PR to be merged first:

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, highlighting breaking changes as necessary
  • I've prepared draft pull requests for clients and consumer packages to resolve any breaking changes

Comment on lines -345 to -372
if (this.#isAlignmentInProgress) {
return; // Prevent concurrent alignments
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Actually, removed the old logic mainly cause this could be misleading.

If an alignement was in progress, calling alignGroups would have returned right away, so you needed to check getIsAlignmentInProgress to know if something was still running.

With the new #withLock mechanisms. All those operations will naturally be "queued" until the lock got released. So, we won't be running those concurrently, but more sequentially instead.

* wallet. Account groups will either be created or deleted during
* this operation.
*/
OperationInProgress = 'operation-in-progress',
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 struggle to find a good name for this one... Maybe we should also split create/delete into 2 different status 🤔

(deleting is not possible for now though)

Copy link
Contributor

Choose a reason for hiding this comment

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

"CrudOperation"? "Mutation" ? No clue either 😅

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 actually went with in-progress:create-accounts, mainly because we don't have "delete operations".

);
return await operation();
} finally {
this.#status = MultichainAccountWalletStatus.Ready;
Copy link
Contributor

Choose a reason for hiding this comment

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

Don't we need a Error state?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good question 🤔 the main problem I can see with this is... How to get back into the Ready state if that happens? 😅

Copy link
Contributor Author

Choose a reason for hiding this comment

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

After thinking about it, I don't think we need any error state for the moment.

fabiobozzo
fabiobozzo previously approved these changes Sep 9, 2025
@ccharly ccharly force-pushed the feat/multichain-account-service-operation-events branch from db27b9a to 207f2ea Compare September 9, 2025 14:44
@ccharly ccharly marked this pull request as ready for review September 9, 2025 17:14
@ccharly ccharly requested review from a team as code owners September 9, 2025 17:14
fabiobozzo
fabiobozzo previously approved these changes Sep 10, 2025
@ccharly ccharly force-pushed the feat/multichain-account-service-operation-events branch from e16f62a to af6b40e Compare September 11, 2025 10:12
@ccharly ccharly requested review from a team as code owners September 11, 2025 10:12
@ccharly ccharly changed the base branch from main to chore/bump-multichain-accounts-deps September 11, 2025 10:12
@ccharly ccharly force-pushed the feat/multichain-account-service-operation-events branch from af6b40e to cc8a5bd Compare September 11, 2025 10:13
cursor[bot]

This comment was marked as outdated.

cursor[bot]

This comment was marked as outdated.

@ccharly ccharly force-pushed the feat/multichain-account-service-operation-events branch from 0bab851 to a30e2a8 Compare September 11, 2025 12:25
Base automatically changed from chore/bump-multichain-accounts-deps to main September 11, 2025 13:06
@ccharly ccharly force-pushed the feat/multichain-account-service-operation-events branch from a30e2a8 to eb9db81 Compare September 11, 2025 13:10
) {
const release = await this.#lock.acquire();
try {
this.#status = status;
Copy link
Contributor

Choose a reason for hiding this comment

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

Don't we need to validate it's a valid status string, at runtime?

Copy link
Contributor

@fabiobozzo fabiobozzo left a comment

Choose a reason for hiding this comment

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

LGTM

@ccharly ccharly merged commit 29a7354 into main Sep 11, 2025
239 checks passed
@ccharly ccharly deleted the feat/multichain-account-service-operation-events branch September 11, 2025 13:18
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.

2 participants