Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Return non nil values in abci handlers #515

Merged
merged 1 commit into from
Sep 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading