-
-
Notifications
You must be signed in to change notification settings - Fork 187
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
Fix race condition where some token detections can get mistakenly added to the wrong account #956
Conversation
bd8ff11
to
5ab45c6
Compare
Added DO-NOT-MERGE lable until freeze on |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Should we add a test where we ensure the token is added to the correct spot based on chainID?
|
d9347f4
dadcc12
to
d9347f4
Compare
…ed to the wrong account
d9347f4
to
a471da5
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
The code freeze is over, so the |
…ed to the wrong account (#956) Fix race condition causing misattribution for token-detection across networks and accounts
…ed to the wrong account (#956) Fix race condition causing misattribution for token-detection across networks and accounts
…ed to the wrong account (#956) Fix race condition causing misattribution for token-detection across networks and accounts
Currently there exists an issue (exposed by this bug) where if a user changes accounts (account
x
to accounty
) or (changes from networka
to networkb
) right as adetectTokens()
call is occuring, the results of thegetBalancesInSingleCall()
call (withindetectTokens()
) made against addressx
ornetwork
acan get incorrectly misattributed to account
yor
networkb
. This can happen because currentlydetectTokens()
simply callsthis.addDetectedTokens()
on theTokensController
with the detectedtokensToAdd
assuming that when this call occurs in theTokensController
theselectedAddress
orchainId
used to store these detected assets will be the same as the one used to detect them. With sufficiently unfortunate timing this expectation can be broken, and so this PR introduces a pattern (already used in the analogous flow between the NftDetectionController and the NftController, whereby the address and network data are passed along with the detectedToken data to ensure they are stored correctly.Partially fixes: MetaMask/metamask-extension#16349
Checklist