Skip to content

Fix #10081 - Use fetchWithCache to retrieve and store basic gas estim…#10384

Merged
darkwing merged 1 commit intoMetaMask:developfrom
darkwing:gas-fetch-cache
Mar 9, 2021
Merged

Fix #10081 - Use fetchWithCache to retrieve and store basic gas estim…#10384
darkwing merged 1 commit intoMetaMask:developfrom
darkwing:gas-fetch-cache

Conversation

@darkwing
Copy link
Copy Markdown
Contributor

@darkwing darkwing commented Feb 5, 2021

Fixes: #10081

Explanation:

Supercedes #10098 to avoid huge rebase.

It appears we're currently fetching basic gas estimates and storing the result along with last fetched time, and then doing expiration validation, when fetchWithCache can do all of this for us.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Feb 5, 2021

CLA Signature Action: All authors have signed the CLA. You may need to manually re-run the blocking PR check if it doesn't pass in a few minutes.

@darkwing darkwing force-pushed the gas-fetch-cache branch 3 times, most recently from f7354e7 to 879454c Compare February 8, 2021 22:11
@darkwing darkwing dismissed a stale review via 8e9dfa1 February 11, 2021 17:32
@darkwing darkwing force-pushed the gas-fetch-cache branch 4 times, most recently from 67263d7 to a0fad33 Compare February 15, 2021 15:22
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried testing this locally, and it seems as though this call is stalling, not failing. It hangs forever. It happens with the benchmark and the metric tests because it only affects the first pageload. When you refresh, it's fine.

I found some localForage issues that talk about it hanging when trying to open an existing IndexedDB database in a web worker... maybe something similar is happening here? This is the first time we've used this API in the background. It's only been used in the front-end up to now. 🤔

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One solution would be to not await this call. Just keep going. That would get past this problem, but it seems a bit... sketchy 😬 . Is it possible it would mess with future IndexedDB calls? Who knows.

Maybe we can remove the migration altogether? Having junk data leftover is less bad than freezing the page load. Not ideal, but less bad.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or we could just remove these from local storage, and add a comment to remind us to find a way to remove it from local storage later at some point. Maybe we'll need front-end migrations 🤔

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Made an update to see if a value check before attempting to remove will help.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was freezing when opening the database, so I'd be surprised if that helped.

@darkwing darkwing force-pushed the gas-fetch-cache branch 2 times, most recently from 614481d to b0c16bd Compare February 16, 2021 14:51
NiranjanaBinoy added a commit that referenced this pull request Feb 17, 2021
…are now minimal and moved corresponding code to fetchEthGasPriceEstimates
NiranjanaBinoy added a commit that referenced this pull request Feb 18, 2021
…are now minimal and moved corresponding code to fetchEthGasPriceEstimates
danjm pushed a commit that referenced this pull request Feb 18, 2021
…are now minimal and moved corresponding code to fetchEthGasPriceEstimates
NiranjanaBinoy added a commit that referenced this pull request Feb 18, 2021
…are now minimal and moved corresponding code to fetchEthGasPriceEstimates
@darkwing
Copy link
Copy Markdown
Contributor Author

It appears fab22ee makes this PR no longer viable, as we're specific to chains now, so I'll close.

@darkwing darkwing closed this Feb 24, 2021
@github-actions github-actions bot locked and limited conversation to collaborators Feb 24, 2021
@Gudahtt
Copy link
Copy Markdown
Member

Gudahtt commented Feb 24, 2021

I don't believe fab22ee makes this PR any less viable. In fact it was updated specifically to reduce conflicts with this PR.

Custom networks won't benefit from this, as we're not using our gas estimation API for those. But these changes remain just as applicable for Mainnet.

@darkwing darkwing reopened this Feb 24, 2021
@darkwing darkwing force-pushed the gas-fetch-cache branch 2 times, most recently from a14e2cb to cbd5e3b Compare February 25, 2021 16:58
@darkwing darkwing requested review from Gudahtt and brad-decker March 3, 2021 16:41
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: This function is no longer used.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed!

Gudahtt
Gudahtt previously approved these changes Mar 9, 2021
Copy link
Copy Markdown
Member

@Gudahtt Gudahtt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

Gudahtt
Gudahtt previously approved these changes Mar 9, 2021
@Gudahtt
Copy link
Copy Markdown
Member

Gudahtt commented Mar 9, 2021

The CI failure was already fixed on develop - this should pass if rebased.

@darkwing darkwing force-pushed the gas-fetch-cache branch 2 times, most recently from ecd5513 to d6d97f7 Compare March 9, 2021 19:16
@darkwing darkwing merged commit 444d8dd into MetaMask:develop Mar 9, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Use fetchWithCache for retrieving basic gas estimates

3 participants