From 772a182130fe94e700bd32906cdc08ee1f0aa7f9 Mon Sep 17 00:00:00 2001 From: Jernej Kos Date: Wed, 1 Nov 2023 16:02:28 +0100 Subject: [PATCH] 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. --- .changelog/5423.bugfix.md | 4 ++++ go/consensus/cometbft/full/common.go | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) create mode 100644 .changelog/5423.bugfix.md diff --git a/.changelog/5423.bugfix.md b/.changelog/5423.bugfix.md new file mode 100644 index 00000000000..9313cfc25cb --- /dev/null +++ b/.changelog/5423.bugfix.md @@ -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. diff --git a/go/consensus/cometbft/full/common.go b/go/consensus/cometbft/full/common.go index 1fa99580b17..6b5fea20535 100644 --- a/go/consensus/cometbft/full/common.go +++ b/go/consensus/cometbft/full/common.go @@ -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 {