Skip to content

Commit

Permalink
Fix non-initialized return values
Browse files Browse the repository at this point in the history
  • Loading branch information
Eric-Warehime committed Mar 5, 2024
1 parent 9ec7992 commit 96d900d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 18 deletions.
2 changes: 1 addition & 1 deletion protocol/app/prepare/full_node_prepare_proposal.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@ func FullNodePrepareProposalHandler() sdk.PrepareProposalHandler {
recordErrorMetricsWithLabel(metrics.PrepareProposalTxs)

// Return an empty response if the node is running in full-node mode so that the proposal fails.
return &EmptyResponse, nil
return &abci.ResponsePrepareProposal{Txs: [][]byte{}}, nil
}
}
30 changes: 13 additions & 17 deletions protocol/app/prepare/prepare_proposal.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,6 @@ import (
slinkyabci "github.com/skip-mev/slinky/abci/types"
)

var (
EmptyResponse = abci.ResponsePrepareProposal{Txs: [][]byte{}}
)

// PricesTxResponse represents a response for creating `UpdateMarketPrices` tx.
type PricesTxResponse struct {
Tx []byte
Expand Down Expand Up @@ -71,7 +67,7 @@ func PrepareProposalHandler(
if err != nil {
ctx.Logger().Error(fmt.Sprintf("NewPrepareProposalTxs error: %v", err))
recordErrorMetricsWithLabel(metrics.PrepareProposalTxs)
return &EmptyResponse, nil
return &abci.ResponsePrepareProposal{Txs: [][]byte{}}, nil
}

var extCommitBzTx []byte
Expand All @@ -84,49 +80,49 @@ func PrepareProposalHandler(
if err != nil {
ctx.Logger().Error(fmt.Sprintf("GetValidMarketPriceUpdates error: %v", err))
recordErrorMetricsWithLabel(metrics.PricesTx)
return &EmptyResponse, nil
return &abci.ResponsePrepareProposal{Txs: [][]byte{}}, nil
}

// Gather "FixedSize" group messages.
pricesTxResp, err := EncodeMarketPriceUpdates(txConfig, msg)
if err != nil {
ctx.Logger().Error(fmt.Sprintf("GetUpdateMarketPricesTx error: %v", err))
recordErrorMetricsWithLabel(metrics.PricesTx)
return &EmptyResponse, nil
return &abci.ResponsePrepareProposal{Txs: [][]byte{}}, nil
}
err = txs.SetUpdateMarketPricesTx(pricesTxResp.Tx)
if err != nil {
ctx.Logger().Error(fmt.Sprintf("SetUpdateMarketPricesTx error: %v", err))
recordErrorMetricsWithLabel(metrics.PricesTx)
return &EmptyResponse, nil
return &abci.ResponsePrepareProposal{Txs: [][]byte{}}, nil
}

fundingTxResp, err := GetAddPremiumVotesTx(ctx, txConfig, perpetualKeeper)
if err != nil {
ctx.Logger().Error(fmt.Sprintf("GetAddPremiumVotesTx error: %v", err))
recordErrorMetricsWithLabel(metrics.FundingTx)
return &EmptyResponse, nil
return &abci.ResponsePrepareProposal{Txs: [][]byte{}}, nil
}
err = txs.SetAddPremiumVotesTx(fundingTxResp.Tx)
if err != nil {
ctx.Logger().Error(fmt.Sprintf("SetAddPremiumVotesTx error: %v", err))
recordErrorMetricsWithLabel(metrics.FundingTx)
return &EmptyResponse, nil
return &abci.ResponsePrepareProposal{Txs: [][]byte{}}, nil
}

acknowledgeBridgesTxResp, err := GetAcknowledgeBridgesTx(ctx, txConfig, bridgeKeeper)
if err != nil {
ctx.Logger().Error(fmt.Sprintf("GetAcknowledgeBridgesTx error: %v", err))
recordErrorMetricsWithLabel(metrics.AcknowledgeBridgesTx)
return &EmptyResponse, nil
return &abci.ResponsePrepareProposal{Txs: [][]byte{}}, nil
}
// Set AcknowledgeBridgesTx whether there are bridge events or not to ensure
// consistent ordering of txs received by ProcessProposal.
err = txs.SetAcknowledgeBridgesTx(acknowledgeBridgesTxResp.Tx)
if err != nil {
ctx.Logger().Error(fmt.Sprintf("SetAcknowledgeBridgesTx error: %v", err))
recordErrorMetricsWithLabel(metrics.AcknowledgeBridgesTx)
return &EmptyResponse, nil
return &abci.ResponsePrepareProposal{Txs: [][]byte{}}, nil
}

// Gather "Other" group messages.
Expand All @@ -139,7 +135,7 @@ func PrepareProposalHandler(
if err != nil {
ctx.Logger().Error(fmt.Sprintf("AddOtherTxs error: %v", err))
recordErrorMetricsWithLabel(metrics.OtherTxs)
return &EmptyResponse, nil
return &abci.ResponsePrepareProposal{Txs: [][]byte{}}, nil
}
}

Expand All @@ -149,13 +145,13 @@ func PrepareProposalHandler(
if err != nil {
ctx.Logger().Error(fmt.Sprintf("GetProposedOperationsTx error: %v", err))
recordErrorMetricsWithLabel(metrics.OperationsTx)
return &EmptyResponse, nil
return &abci.ResponsePrepareProposal{Txs: [][]byte{}}, nil
}
err = txs.SetProposedOperationsTx(operationsTxResp.Tx)
if err != nil {
ctx.Logger().Error(fmt.Sprintf("SetProposedOperationsTx error: %v", err))
recordErrorMetricsWithLabel(metrics.OperationsTx)
return &EmptyResponse, nil
return &abci.ResponsePrepareProposal{Txs: [][]byte{}}, nil
}

// Try to pack in more "Other" txs.
Expand All @@ -167,7 +163,7 @@ func PrepareProposalHandler(
if err != nil {
ctx.Logger().Error(fmt.Sprintf("AddOtherTxs (additional) error: %v", err))
recordErrorMetricsWithLabel(metrics.OtherTxs)
return &EmptyResponse, nil
return &abci.ResponsePrepareProposal{Txs: [][]byte{}}, nil
}
}
}
Expand All @@ -176,7 +172,7 @@ func PrepareProposalHandler(
if err != nil {
ctx.Logger().Error(fmt.Sprintf("GetTxsInOrder error: %v", err))
recordErrorMetricsWithLabel(metrics.GetTxsInOrder)
return &EmptyResponse, nil
return &abci.ResponsePrepareProposal{Txs: [][]byte{}}, nil
}

// Record a success metric.
Expand Down

0 comments on commit 96d900d

Please sign in to comment.