Skip to content

Commit

Permalink
go/consensus: Do not crash on nil result from Commit
Browse files Browse the repository at this point in the history
The Commit function can return both a nil error and a nil result in case
the given block is not available yet.
  • Loading branch information
kostko committed Nov 1, 2023
1 parent bd0166e commit c27dea7
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 4 additions & 0 deletions .changelog/5423.bugfix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
go/consensus: Do not crash on nil result from Commit

The Commit function can return both a nil error and a nil result in case
the given block is not available yet.
2 changes: 1 addition & 1 deletion go/consensus/cometbft/full/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -586,7 +586,7 @@ func (n *commonNode) getLightBlock(ctx context.Context, height int64, allowPendi
}

commit, err := cmtcore.Commit(n.rpcCtx, &tmHeight)
if err == nil && commit.Header != nil {
if err == nil && commit != nil && commit.Header != nil {
lb.SignedHeader = &commit.SignedHeader
tmHeight = commit.Header.Height
} else if allowPending {
Expand Down

0 comments on commit c27dea7

Please sign in to comment.