Skip to content

Commit

Permalink
Fix NPE trying to access non existent ChainID
Browse files Browse the repository at this point in the history
ChainID is allowed to be unset.
  • Loading branch information
piersy authored and hbandura committed Feb 1, 2024
1 parent d43b9f4 commit fdbd2a0
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions internal/ethapi/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -752,10 +752,11 @@ func addEthCompatibilityFields(ctx context.Context, response map[string]interfac
var gasLimit uint64
var err error

// For mainnet, alfajores and baklava we have a set of hardcoded values derived from historical state that we can use.
v := params.PreGingerbreadNetworkGasLimits[b.ChainConfig().ChainID.Uint64()]
if v != nil {
gasLimit = v.Limit(header.Number)
// For mainnet, alfajores and baklava we have a set of hardcoded values derived from historical state that we can
// use, note ChainID might be unset, so we need to account for that.
chainId := b.ChainConfig().ChainID
if chainId != nil && params.PreGingerbreadNetworkGasLimits[chainId.Uint64()] != nil {
gasLimit = params.PreGingerbreadNetworkGasLimits[chainId.Uint64()].Limit(header.Number)
} else {
// If no hardcoded limits are available for this network then we will try to look up the gas limit in the state.
hash := header.Hash()
Expand Down

0 comments on commit fdbd2a0

Please sign in to comment.