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

Fetch eth_gasprice in send flow on non-Mainnet networks #10444

Merged
merged 9 commits into from
Feb 19, 2021

Conversation

NiranjanaBinoy
Copy link
Contributor

Fixes: #10003

Explanation:

The issue was that the gasPrice fetched for the test networks while performing send is the same as the Mainnet.

The fix will check for the network type and, if it is a test network then the gasprice will be fetched using gasPrice() from ethjs which in turn uses ethjs-query.
If user switches the network from Send Eth page, the gas values will be updated for the new network.

Manual testing steps:

gasprice.mov
gasprice_refresh.mov

@NiranjanaBinoy NiranjanaBinoy requested a review from a team as a code owner February 13, 2021 01:37
@github-actions
Copy link
Contributor

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.

Copy link
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.

There is a fair bit of overlap between this PR and #10384

In #10384 the fetchBasicGasEstimates function is updated to remove the dependence upon the storage helpers (getStorageItem and setStorageItem), as it relies upon browser fetch caching instead. We'll still want caching for the eth.gasPrice result though as that won't be handled by fetch browser caching (since it's an internal call that we can't easily augment, and it uses POST).

So to that end, perhaps it would be better to put all of the new logic changes made in fetchBasicGasEstimates in its own if block or function. That would help reduce conflicts.

ui/app/ducks/gas/gas.duck.js Outdated Show resolved Hide resolved
ui/app/ducks/gas/gas.duck.js Outdated Show resolved Hide resolved
@metamaskbot
Copy link
Collaborator

Builds ready [7f56cda]
Page Load Metrics (537 ± 26 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint43645573
domContentLoaded3605935355426
load3655945375426
domInteractive3605935355426

ui/app/ducks/gas/gas.duck.js Show resolved Hide resolved

async function fetchEthGasPriceEstimates(state) {
const chainId = getCurrentChainId(state);
const timeLastRetrieved =
Copy link
Member

Choose a reason for hiding this comment

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

Nit: Not super important, but, it would be slightly faster if we used Promise.all to ask for the last retrieved time and the basic price estimates in parallel.

@Gudahtt
Copy link
Member

Gudahtt commented Feb 17, 2021

Thanks for addressing my last review! The new changes look good, aside from additional one problem that I found.

@metamaskbot
Copy link
Collaborator

Builds ready [1cd3cfd]
Page Load Metrics (613 ± 35 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint45786184
domContentLoaded4096946117235
load4106956137235
domInteractive4096936117235

@Gudahtt
Copy link
Member

Gudahtt commented Feb 18, 2021

Something got messed up with that last update 🤔 You pulled in a bunch of unrelated commits somehow.

@metamaskbot
Copy link
Collaborator

Builds ready [1f8b8dd]
Page Load Metrics (571 ± 24 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint48715773
domContentLoaded3696295705124
load3716305715024
domInteractive3696295705124

@NiranjanaBinoy NiranjanaBinoy force-pushed the non-mainnet-gas-price-10003 branch from 1f8b8dd to 9ecf4ab Compare February 18, 2021 19:02
@metamaskbot
Copy link
Collaborator

Builds ready [53306eb]
Page Load Metrics (679 ± 76 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint5010665147
domContentLoaded548117267715976
load549117367915976
domInteractive548117167715976

Gudahtt
Gudahtt previously approved these changes Feb 18, 2021
Copy link
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!

ui/app/ducks/gas/gas.duck.js Outdated Show resolved Hide resolved
Co-authored-by: Mark Stacey <[email protected]>
@metamaskbot
Copy link
Collaborator

Builds ready [4cf5821]
Page Load Metrics (573 ± 36 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint498463105
domContentLoaded3616525717637
load3626535737636
domInteractive3616515717636

@NiranjanaBinoy NiranjanaBinoy changed the title Mainnet gas price estimates used in send flow on non-Mainnet networks Fetch eth_gasprice in send flow on non-Mainnet networks Feb 19, 2021
@NiranjanaBinoy NiranjanaBinoy merged commit fab22ee into develop Feb 19, 2021
@NiranjanaBinoy NiranjanaBinoy deleted the non-mainnet-gas-price-10003 branch February 19, 2021 02:48
@github-actions github-actions bot locked and limited conversation to collaborators Feb 19, 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.

Mainnet gas price estimates used in send flow on non-Mainnet networks
3 participants