diff --git a/baseapp/abci_utils.go b/baseapp/abci_utils.go index 366179b2ac53..3ba22fcadc09 100644 --- a/baseapp/abci_utils.go +++ b/baseapp/abci_utils.go @@ -263,3 +263,19 @@ func NoOpProcessProposal() sdk.ProcessProposalHandler { return &abci.ResponseProcessProposal{Status: abci.ResponseProcessProposal_ACCEPT}, nil } } + +// NoOpExtendVote defines a no-op ExtendVote handler. It will always return an +// empty byte slice as the vote extension. +func NoOpExtendVote() sdk.ExtendVoteHandler { + return func(_ sdk.Context, _ *abci.RequestExtendVote) (*abci.ResponseExtendVote, error) { + return &abci.ResponseExtendVote{VoteExtension: []byte{}}, nil + } +} + +// NoOpVerifyVoteExtensionHandler defines a no-op VerifyVoteExtension handler. It +// will always return an ACCEPT status with no error. +func NoOpVerifyVoteExtensionHandler() sdk.VerifyVoteExtensionHandler { + return func(_ sdk.Context, _ *abci.RequestVerifyVoteExtension) (*abci.ResponseVerifyVoteExtension, error) { + return &abci.ResponseVerifyVoteExtension{Status: abci.ResponseVerifyVoteExtension_ACCEPT}, nil + } +} diff --git a/baseapp/baseapp.go b/baseapp/baseapp.go index d008f201ef72..7d2b8cccc9bd 100644 --- a/baseapp/baseapp.go +++ b/baseapp/baseapp.go @@ -206,11 +206,15 @@ func NewBaseApp( if app.prepareProposal == nil { app.SetPrepareProposal(abciProposalHandler.PrepareProposalHandler()) } - if app.processProposal == nil { app.SetProcessProposal(abciProposalHandler.ProcessProposalHandler()) } - + if app.extendVote == nil { + app.SetExtendVoteHandler(NoOpExtendVote()) + } + if app.verifyVoteExt == nil { + app.SetVerifyVoteExtensionHandler(NoOpVerifyVoteExtensionHandler()) + } if app.interBlockCache != nil { app.cms.SetInterBlockCache(app.interBlockCache) } diff --git a/baseapp/options.go b/baseapp/options.go index c30488df4ee7..794df1306ee5 100644 --- a/baseapp/options.go +++ b/baseapp/options.go @@ -300,6 +300,22 @@ func (app *BaseApp) SetPrepareProposal(handler sdk.PrepareProposalHandler) { app.prepareProposal = handler } +func (app *BaseApp) SetExtendVoteHandler(handler sdk.ExtendVoteHandler) { + if app.sealed { + panic("SetExtendVoteHandler() on sealed BaseApp") + } + + app.extendVote = handler +} + +func (app *BaseApp) SetVerifyVoteExtensionHandler(handler sdk.VerifyVoteExtensionHandler) { + if app.sealed { + panic("SetVerifyVoteExtensionHandler() on sealed BaseApp") + } + + app.verifyVoteExt = handler +} + // SetStoreMetrics sets the prepare proposal function for the BaseApp. func (app *BaseApp) SetStoreMetrics(gatherer metrics.StoreMetrics) { if app.sealed {