Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

race condition in smartWallet addBrand handling #6689

Closed
1 task done
turadg opened this issue Dec 16, 2022 · 0 comments · Fixed by #6999
Closed
1 task done

race condition in smartWallet addBrand handling #6689

turadg opened this issue Dec 16, 2022 · 0 comments · Fixed by #6999
Assignees
Labels
bug Something isn't working vaults_triage DO NOT USE wallet
Milestone

Comments

@turadg
Copy link
Member

turadg commented Dec 16, 2022

Describe the bug

In some versions of XS, the non-init updateBalance hits before the init one, causing an assert to fail when checking for the presence of the key in the collection.

In general while the purse is guaranteed to see the messages getCurrentAmount and getCurrentAmountNotifier in order, there is no guarantee those will be resolved in the same order. And even if they were, E.when and the observeNotifier may not make any guarantee about the number of turns or cranks that may occur.

// publish purse's balance and changes
E.when(
E(purse).getCurrentAmount(),
balance => helper.updateBalance(purse, balance, 'init'),
err =>
console.error(address, 'initial purse balance publish failed', err),
);
observeNotifier(E(purse).getCurrentAmountNotifier(), {
updateState(balance) {
helper.updateBalance(purse, balance);
},
fail(reason) {
console.error(address, `failed updateState observer`, reason);
},
});

To Reproduce

Not practical to reproduce. Just fix through code analysis.

Expected behavior

No assertion failure if promises resolve in another valid resolution order.

Platform Environment

XS

Additional context

#6689 (comment)

Screenshots

If applicable, add screenshots to help explain your problem, especially for UI interactions.

@turadg turadg added bug Something isn't working wallet labels Dec 16, 2022
@turadg turadg self-assigned this Dec 16, 2022
@rowgraus rowgraus added the vaults_triage DO NOT USE label Jan 3, 2023
@ivanlei ivanlei added this to the Vaults RC0 milestone Feb 1, 2023
@mergify mergify bot closed this as completed in #6999 Feb 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working vaults_triage DO NOT USE wallet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants