-
Notifications
You must be signed in to change notification settings - Fork 5k
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 default gas race condition #8490
Conversation
This depends upon #8489 |
I do think this solution is sound in principle at least. Though preventing interactions with the transaction in the UI while the default gas is loading would be ideal as well. |
4c764ec
to
27b6b2c
Compare
seems like we need some rxjs flow that ignores stale values |
Builds ready [27b6b2c]
Page Load Metrics (692 ± 37 ms)
|
Builds ready [27b6b2c]
Page Load Metrics (651 ± 17 ms)
|
Builds ready [27b6b2c]
Page Load Metrics (674 ± 25 ms)
|
Builds ready [27b6b2c]
Page Load Metrics (660 ± 37 ms)
|
Builds ready [27b6b2c]
Page Load Metrics (639 ± 15 ms)
|
e67bc95
to
c75b58a
Compare
Builds ready [c75b58a]
Page Load Metrics (689 ± 28 ms)
|
A race condition exists where after adding an unapproved transaction, it could be mutated and then replaced when the default gas parameters are set. This happens because the transaction is added to state and broadcast before the default gas parameters are set, because calculating the default gas parameters to use takes some time. Once they've been calculated, the false assumption was made that the transaction hadn't changed. The method responsible for setting the default gas now retrieves an up-to-date copy of `txMeta`, and conditionally sets the defaults only if they haven't yet been set. This race condition was introduced in #2962, though that PR also added a loading screen that avoided this issue by preventing the user from interacting with the transaction until after the gas had been estimated. Unfortunately this loading screen was not carried forward to the new UI.
c75b58a
to
f00fa8b
Compare
Builds ready [f00fa8b]
Page Load Metrics (646 ± 30 ms)
|
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.
Yes, I believe this is good.
A race condition exists where after adding an unapproved transaction, it could be mutated and then replaced when the default gas parameters are set. This happens because the transaction is added to state and broadcast before the default gas parameters are set, because calculating the default gas parameters to use takes some time. Once they've been calculated, the false assumption was made that the transaction hadn't changed.
The method responsible for setting the default gas now retrieves an up-to-date copy of
txMeta
, and conditionally sets the defaults only if they haven't yet been set.This race condition was introduced in #2962, though that PR also added a loading screen that avoided this issue by preventing the user from interacting with the transaction until after the gas had been estimated. Unfortunately this loading screen was not carried forward to the new UI.