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

[GasController] Check for undefined basefeePerGas #703

Merged
merged 3 commits into from
Mar 5, 2022

Conversation

peak3d
Copy link
Contributor

@peak3d peak3d commented Mar 3, 2022

PR Title
GasController: Don't fall back to eth_gasPrice if node returns empty fee history

Description
go-ethereum based chains never return empty baseFeePerGas because this is omitted in the serializer:

type feeHistoryResult struct {
	OldestBlock  *hexutil.Big     `json:"oldestBlock"`
	Reward       [][]*hexutil.Big `json:"reward,omitempty"`
	BaseFee      []*hexutil.Big   `json:"baseFeePerGas,omitempty"` <---
	GasUsedRatio []float64        `json:"gasUsedRatio"`
}

Current code checks for baseFeePerGas.length > 0 without checking for the occurence of this element.
This leads to an exception and in later flow to fallback to eth_gasPrice mode

  • FIXED:
    no feeMarket mode available in case one of past requests return no results

Checklist

  • Tests are included if applicable
  • Any added code is fully documented

Issue

@peak3d peak3d requested a review from a team as a code owner March 3, 2022 08:04
Copy link
Contributor

@mcmire mcmire left a comment

Choose a reason for hiding this comment

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

Good catch! I tried to read the geth source code when implementing this file but I obviously didn't see this. Makes total sense though. Would you be willing to add tests for this?

@peak3d
Copy link
Contributor Author

peak3d commented Mar 3, 2022

Good catch! I tried to read the geth source code when implementing this file but I obviously didn't see this. Makes total sense though. Would you be willing to add tests for this?

done

@mcmire
Copy link
Contributor

mcmire commented Mar 3, 2022

Looks like this is out of date, would you mind rebasing? Thanks.

Copy link
Contributor

@mcmire mcmire left a comment

Choose a reason for hiding this comment

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

LGTM!

@mcmire
Copy link
Contributor

mcmire commented Mar 4, 2022

@peak3d Apologies — do you mind rebasing this again? I will make sure to get this in today.

@peak3d
Copy link
Contributor Author

peak3d commented Mar 4, 2022

Apologies — do you mind rebasing this again? I will make sure to get this in today

NP, but I guess I'll have to rebase one of my two commits depending which one you merge first because they affect the same file.....
I'm CET timezone, so would be great if you merge at least one so I can care about the other....

@mcmire mcmire merged commit 777f5da into MetaMask:main Mar 5, 2022
soralit pushed a commit to KeystoneHQ/controllers that referenced this pull request Mar 14, 2022
go-ethereum based chains never return empty baseFeePerGas because this is omitted in the serializer:

```
type feeHistoryResult struct {
	OldestBlock  *hexutil.Big     `json:"oldestBlock"`
	Reward       [][]*hexutil.Big `json:"reward,omitempty"`
	BaseFee      []*hexutil.Big   `json:"baseFeePerGas,omitempty"` <---
	GasUsedRatio []float64        `json:"gasUsedRatio"`
}
```

Current code checks for baseFeePerGas.length > 0 without checking for the occurence of this element.
This leads to an exception and in later flow to fallback to eth_gasPrice mode

FIXED: no feeMarket mode available in case one of past requests return no results
MajorLift pushed a commit that referenced this pull request Oct 11, 2023
go-ethereum based chains never return empty baseFeePerGas because this is omitted in the serializer:

```
type feeHistoryResult struct {
	OldestBlock  *hexutil.Big     `json:"oldestBlock"`
	Reward       [][]*hexutil.Big `json:"reward,omitempty"`
	BaseFee      []*hexutil.Big   `json:"baseFeePerGas,omitempty"` <---
	GasUsedRatio []float64        `json:"gasUsedRatio"`
}
```

Current code checks for baseFeePerGas.length > 0 without checking for the occurence of this element.
This leads to an exception and in later flow to fallback to eth_gasPrice mode

FIXED: no feeMarket mode available in case one of past requests return no results
MajorLift pushed a commit that referenced this pull request Oct 11, 2023
go-ethereum based chains never return empty baseFeePerGas because this is omitted in the serializer:

```
type feeHistoryResult struct {
	OldestBlock  *hexutil.Big     `json:"oldestBlock"`
	Reward       [][]*hexutil.Big `json:"reward,omitempty"`
	BaseFee      []*hexutil.Big   `json:"baseFeePerGas,omitempty"` <---
	GasUsedRatio []float64        `json:"gasUsedRatio"`
}
```

Current code checks for baseFeePerGas.length > 0 without checking for the occurence of this element.
This leads to an exception and in later flow to fallback to eth_gasPrice mode

FIXED: no feeMarket mode available in case one of past requests return no results
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants