-
-
Notifications
You must be signed in to change notification settings - Fork 215
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: Remove async operation from updateTransactionGasFees
#5539
fix: Remove async operation from updateTransactionGasFees
#5539
Conversation
@@ -3881,7 +3881,7 @@ export class TransactionController extends BaseController< | |||
log('Updated simulation data', transactionId, simulationData); | |||
} | |||
|
|||
#onGasFeePollerTransactionUpdate({ | |||
async #onGasFeePollerTransactionUpdate({ |
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.
This is fired from an event listener, so there is technically now a risk that if we have a very slow update, that they begin to overlap.
Should we add a mutex to prevent two happening at once?
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.
Good call Matthew, added gasFeeUpdateMutexes
map for locking same transactionId
gas updates now.
975db53
to
fbd9969
Compare
const release = await mutex.acquire(); | ||
try { | ||
const transaction = this.getTransaction(transactionId) as TransactionMeta; | ||
const isEIP1559Compatible = |
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.
Sorry Goktug, I've looked into this deeper and I don't think we need to call getEIP1559Compatability
at all meaning this doesn't need to be async
and no mutexes.
Because we already call this inside addTransaction
and then go through validateEIP1559Compatibility
which would throw if there was a maxFeePerGas
or maxPriorityFeePerGas
provided but the network wasn't EIP-1159.
So we could instead just set the type
early at that point in addTransaction
based on the existing compatibility call, assuming the user didn't explicit specify the legacy type.
Then here, we would just trust the envelope type?
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.
Thanks Matthew, I added a tiny function that sets type
after validation if nothing defined, so we make sure that type is always present and it give us the flexibility to remove that async check.
3230990
to
b6decfe
Compare
Explanation
This PR aims to fix an issue where
updateTransactionGasFees
updater rejects updating draft state with following error:TypeError: Cannot perform 'get' on a proxy that has been revoked
The fix is to remove that async operation because it's unnecessary to check it again since it's been check while
addTransaction
References
Changelog
@metamask/transaction-controller
enableTxParamsGasFeeUpdates
is set totrue
Checklist