Skip to content

Commit

Permalink
chore: fix nil pointer (ethereum-optimism#394)
Browse files Browse the repository at this point in the history
When error occurs, `block` is `nil` and `block.Height` will cause a nil
pointer panic. Uncovered in local deployment
  • Loading branch information
SebastianElvis authored Jun 21, 2024
1 parent 9182921 commit 693ea70
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion clientcontroller/babylon/consumer.go
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,10 @@ func (bc *BabylonConsumerController) QueryLatestBlockHeight() (uint64, error) {
if err != nil || len(blocks) != 1 {
// try query comet block if the index block query is not available
block, err := bc.queryCometBestBlock()
return block.Height, err
if err != nil {
return 0, err
}
return block.Height, nil
}

return blocks[0].Height, nil
Expand Down

0 comments on commit 693ea70

Please sign in to comment.