Skip to content

Commit

Permalink
fix: Return non nil values in abci handlers (#515)
Browse files Browse the repository at this point in the history
  • Loading branch information
rbajollari authored Sep 17, 2024
1 parent 7b7daca commit 960e5e1
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
14 changes: 7 additions & 7 deletions x/oracle/abci/proposal.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ func (h *ProposalHandler) PrepareProposalHandler() sdk.PrepareProposalHandler {

err := baseapp.ValidateVoteExtensions(ctx, h.stakingKeeper, req.Height, ctx.ChainID(), req.LocalLastCommit)
if err != nil {
return nil, err
return &cometabci.ResponsePrepareProposal{Txs: make([][]byte, 0)}, err
}

if req.Txs == nil {
Expand All @@ -63,7 +63,7 @@ func (h *ProposalHandler) PrepareProposalHandler() sdk.PrepareProposalHandler {
"height", req.Height,
err.Error(),
)
return nil, err
return &cometabci.ResponsePrepareProposal{Txs: make([][]byte, 0)}, err
}

proposalTxs := req.Txs
Expand All @@ -72,7 +72,7 @@ func (h *ProposalHandler) PrepareProposalHandler() sdk.PrepareProposalHandler {
if voteExtensionsEnabled {
exchangeRateVotes, err := h.generateExchangeRateVotes(ctx, req.LocalLastCommit)
if err != nil {
return nil, err
return &cometabci.ResponsePrepareProposal{Txs: make([][]byte, 0)}, err
}

injectedVoteExtTx := AggregateExchangeRateVotes{
Expand All @@ -85,7 +85,7 @@ func (h *ProposalHandler) PrepareProposalHandler() sdk.PrepareProposalHandler {
bz, err := json.Marshal(injectedVoteExtTx)
if err != nil {
h.logger.Error("failed to encode injected vote extension tx", "err", err)
return nil, oracletypes.ErrEncodeInjVoteExt
return &cometabci.ResponsePrepareProposal{Txs: make([][]byte, 0)}, oracletypes.ErrEncodeInjVoteExt
}

// Inject a placeholder tx into the proposal s.t. validators can decode, verify,
Expand Down Expand Up @@ -122,15 +122,15 @@ func (h *ProposalHandler) ProcessProposalHandler() sdk.ProcessProposalHandler {
"height", req.Height,
err.Error(),
)
return nil, err
return &cometabci.ResponseProcessProposal{Status: cometabci.ResponseProcessProposal_REJECT}, err
}

voteExtensionsEnabled := VoteExtensionsEnabled(ctx)
if voteExtensionsEnabled {
var injectedVoteExtTx AggregateExchangeRateVotes
if err := json.Unmarshal(req.Txs[0], &injectedVoteExtTx); err != nil {
h.logger.Error("failed to decode injected vote extension tx", "err", err)
return &cometabci.ResponseProcessProposal{Status: cometabci.ResponseProcessProposal_REJECT}, nil
return &cometabci.ResponseProcessProposal{Status: cometabci.ResponseProcessProposal_REJECT}, err
}
err := baseapp.ValidateVoteExtensions(
ctx,
Expand All @@ -140,7 +140,7 @@ func (h *ProposalHandler) ProcessProposalHandler() sdk.ProcessProposalHandler {
injectedVoteExtTx.ExtendedCommitInfo,
)
if err != nil {
return nil, err
return &cometabci.ResponseProcessProposal{Status: cometabci.ResponseProcessProposal_REJECT}, err
}

// Verify the proposer's oracle exchange rate votes by computing the same
Expand Down
6 changes: 3 additions & 3 deletions x/oracle/abci/voteextension.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ func (h *VoteExtensionHandler) ExtendVoteHandler() sdk.ExtendVoteHandler {
if h.oracleKeeper.PriceFeeder.Oracle == nil {
err := fmt.Errorf("price feeder oracle not set")
h.logger.Error(err.Error())
return nil, err
return &cometabci.ResponseExtendVote{VoteExtension: []byte{}}, err
}
prices := h.oracleKeeper.PriceFeeder.Oracle.GetPrices()
exchangeRatesStr := oracle.GenerateExchangeRatesString(prices)
Expand All @@ -75,7 +75,7 @@ func (h *VoteExtensionHandler) ExtendVoteHandler() sdk.ExtendVoteHandler {
"height", req.Height,
err.Error(),
)
return nil, err
return &cometabci.ResponseExtendVote{VoteExtension: []byte{}}, err
}

// Filter out rates which aren't included in the AcceptList.
Expand All @@ -99,7 +99,7 @@ func (h *VoteExtensionHandler) ExtendVoteHandler() sdk.ExtendVoteHandler {
"height", req.Height,
err.Error(),
)
return nil, err
return &cometabci.ResponseExtendVote{VoteExtension: []byte{}}, err
}
h.logger.Info(
"created vote extension",
Expand Down

0 comments on commit 960e5e1

Please sign in to comment.