Skip to content

Commit

Permalink
default accept nil VE
Browse files Browse the repository at this point in the history
  • Loading branch information
davidterpay committed Apr 11, 2024
1 parent e51e6c2 commit 4262f1b
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
6 changes: 6 additions & 0 deletions abci/strategies/codec/codec_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,4 +151,10 @@ func TestCompressionExtendedCommitCodec(t *testing.T) {
// make sure it's the same
require.Equal(t, eci, decodedEci)
})

t.Run("test decoding empty byte array", func(t *testing.T) {
codec := compression.NewCompressionExtendedCommitCodec(compression.NewDefaultExtendedCommitCodec(), compression.NewZStdCompressor())
_, err := codec.Decode([]byte{})
require.NoError(t, err)
})
}
11 changes: 11 additions & 0 deletions abci/ve/vote_extension.go
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,17 @@ func (h *VoteExtensionHandler) VerifyVoteExtensionHandler() sdk.VerifyVoteExtens
h.logger.Error("VerifyVoteExtensionHandler received a nil request")
return nil, err
}

// By default, we accept empty vote extensions.
if len(req.VoteExtension) == 0 {
h.logger.Info(
"empty vote extension",
"height", req.Height,
)

return &cometabci.ResponseVerifyVoteExtension{Status: cometabci.ResponseVerifyVoteExtension_ACCEPT}, nil
}

// decode the vote-extension bytes
voteExtension, err := h.voteExtensionCodec.Decode(req.VoteExtension)
if err != nil {
Expand Down

0 comments on commit 4262f1b

Please sign in to comment.