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

[assets-controllers] Prevent overlapping token rate updates #3606

Closed
Gudahtt opened this issue Dec 1, 2023 · 0 comments · Fixed by #3635
Closed

[assets-controllers] Prevent overlapping token rate updates #3606

Gudahtt opened this issue Dec 1, 2023 · 0 comments · Fixed by #3635
Assignees
Labels

Comments

@Gudahtt
Copy link
Member

Gudahtt commented Dec 1, 2023

We don't currently prevent token rate updates from overlapping with each other. For example, if the same token rate update is requested twice in a row in quick succession, we will perform the update twice concurrently.

Instead we should keep track of in-progress token updates, and prevent additional redundant updates from being triggered.
If we get two calls asking for the same update, we can return the results from the first call to both callers.

@Gudahtt Gudahtt added enhancement New feature or request team-wallet-framework labels Dec 1, 2023
@Gudahtt Gudahtt self-assigned this Dec 1, 2023
Gudahtt added a commit that referenced this issue Dec 7, 2023
Previously it was possible for two redundant token rate updates to be
ongoing at the same time. This is non-optimal for performance reasons,
and because the answer might change between the two requests and get
persisted in the wrong order.

We now guard against this by storing in-progress updates as a private
instance variable. Any redundant calls will wait on the in-progress
call to finish, then return as a no-op.

Fixes #3606
Gudahtt added a commit that referenced this issue Dec 7, 2023
Previously it was possible for two redundant token rate updates to be
ongoing at the same time. This is non-optimal for performance reasons,
and because the answer might change between the two requests and get
persisted in the wrong order.

We now guard against this by storing in-progress updates as a private
instance variable. Any redundant calls will wait on the in-progress
call to finish, then return as a no-op.

Fixes #3606
Gudahtt added a commit that referenced this issue Dec 7, 2023
Previously it was possible for two redundant token rate updates to be
ongoing at the same time. This is non-optimal for performance reasons,
and because the answer might change between the two requests and get
persisted in the wrong order.

We now guard against this by storing in-progress updates as a private
instance variable. Any redundant calls will wait on the in-progress
call to finish, then return as a no-op.

Fixes #3606
Gudahtt added a commit that referenced this issue Dec 7, 2023
Previously it was possible for two redundant token rate updates to be
ongoing at the same time. This is non-optimal for performance reasons,
and because the answer might change between the two requests and get
persisted in the wrong order.

We now guard against this by storing in-progress updates as a private
instance variable. Any redundant calls will wait on the in-progress
call to finish, then return as a no-op.

Fixes #3606
Gudahtt added a commit that referenced this issue Dec 8, 2023
Previously it was possible for two redundant token rate updates to be
ongoing at the same time. This is non-optimal for performance reasons,
and because the answer might change between the two requests and get
persisted in the wrong order.

We now guard against this by storing in-progress updates as a private
instance variable. Any redundant calls will wait on the in-progress
call to finish, then return as a no-op.

Fixes #3606
Gudahtt added a commit that referenced this issue Dec 11, 2023
Previously it was possible for two redundant token rate updates to be
ongoing at the same time. This is non-optimal for performance reasons,
and because the answer might change between the two requests and get
persisted in the wrong order.

We now guard against this by storing in-progress updates as a private
instance variable. Any redundant calls will wait on the in-progress
call to finish, then return as a no-op.

Fixes #3606
Gudahtt added a commit that referenced this issue Dec 11, 2023
Previously it was possible for two redundant token rate updates to be
ongoing at the same time. This is non-optimal for performance reasons,
and because the answer might change between the two requests and get
persisted in the wrong order.

We now guard against this by storing in-progress updates as a private
instance variable. Any redundant calls will wait on the in-progress
call to finish, then return as a no-op.

Fixes #3606
Gudahtt added a commit that referenced this issue Dec 12, 2023
Previously it was possible for two redundant token rate updates to be
ongoing at the same time. This is non-optimal for performance reasons,
and because the answer might change between the two requests and get
persisted in the wrong order.

We now guard against this by storing in-progress updates as a private
instance variable. Any redundant calls will wait on the in-progress
call to finish, then return as a no-op.

Fixes #3606
Gudahtt added a commit that referenced this issue Dec 12, 2023
Previously it was possible for two redundant token rate updates to be
ongoing at the same time. This is non-optimal for performance reasons,
and because the answer might change between the two requests and get
persisted in the wrong order.

We now guard against this by storing in-progress updates as a private
instance variable. Any redundant calls will wait on the in-progress
call to finish, then return as a no-op.

Fixes #3606
Gudahtt added a commit that referenced this issue Dec 12, 2023
## Explanation

Previously it was possible for two redundant token rate updates to be
ongoing at the same time. This is non-optimal for performance reasons,
and because the answer might change between the two requests and get
persisted in the wrong order.

We now guard against this by storing in-progress updates as a private
instance variable. Any redundant calls will wait on the in-progress call
to finish, then return as a no-op.

## References

Fixes #3606

## Changelog

### `@metamask/assets-controllers`

-Fixed: Prevent overlapping token rate updates
- This should have no impact to the API at all, it just reduces network
traffic

## Checklist

- [x] I've updated the test suite for new or updated code as appropriate
- [x] I've updated documentation (JSDoc, Markdown, etc.) for new or
updated code as appropriate
- [x] I've highlighted breaking changes using the "BREAKING" category
above as appropriate
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant