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

feat: add metrics to prepare and process proposal (backport #2560) #2564

Merged
merged 2 commits into from
Sep 22, 2023
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
4 changes: 4 additions & 0 deletions app/prepare_proposal.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
package app

import (
"time"

"github.com/celestiaorg/celestia-app/app/ante"
"github.com/celestiaorg/celestia-app/pkg/da"
"github.com/celestiaorg/celestia-app/pkg/shares"
"github.com/celestiaorg/celestia-app/pkg/square"
"github.com/cosmos/cosmos-sdk/telemetry"
abci "github.com/tendermint/tendermint/abci/types"
core "github.com/tendermint/tendermint/proto/tendermint/types"
)
Expand All @@ -16,6 +19,7 @@ import (
// tendermint via the BlockData. Panics indicate a developer error and should
// immediately halt the node for visibility and so they can be quickly resolved.
func (app *App) PrepareProposal(req abci.RequestPrepareProposal) abci.ResponsePrepareProposal {
defer telemetry.MeasureSince(time.Now(), "prepare_proposal")
// create a context using a branch of the state and loaded using the
// proposal height and chain-id
sdkCtx := app.NewProposalContext(core.Header{
Expand Down
6 changes: 5 additions & 1 deletion app/process_proposal.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@ package app
import (
"bytes"
"fmt"
"time"

"github.com/celestiaorg/celestia-app/app/ante"
"github.com/celestiaorg/celestia-app/pkg/da"
"github.com/celestiaorg/celestia-app/pkg/shares"
"github.com/celestiaorg/celestia-app/pkg/square"
blobtypes "github.com/celestiaorg/celestia-app/x/blob/types"
"github.com/cosmos/cosmos-sdk/telemetry"
sdk "github.com/cosmos/cosmos-sdk/types"
abci "github.com/tendermint/tendermint/abci/types"
"github.com/tendermint/tendermint/libs/log"
Expand All @@ -19,11 +21,13 @@ import (
const rejectedPropBlockLog = "Rejected proposal block:"

func (app *App) ProcessProposal(req abci.RequestProcessProposal) (resp abci.ResponseProcessProposal) {
defer telemetry.MeasureSince(time.Now(), "process_proposal")
// In the case of a panic from an unexpected condition, it is better for the liveness of the
// network that we catch it, log an error and vote nil than to crash the node.
defer func() {
if err := recover(); err != nil {
logInvalidPropBlock(app.Logger(), req.Header, fmt.Sprintf("%v", err))
logInvalidPropBlock(app.Logger(), req.Header, fmt.Sprintf("caught panic: %v", err))
telemetry.IncrCounter(1, "process_proposal", "panics")
resp = reject()
}
}()
Expand Down
3 changes: 3 additions & 0 deletions app/validate_txs.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package app

import (
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/telemetry"
sdk "github.com/cosmos/cosmos-sdk/types"
tmbytes "github.com/tendermint/tendermint/libs/bytes"
"github.com/tendermint/tendermint/libs/log"
Expand Down Expand Up @@ -54,6 +55,7 @@ func filterStdTxs(logger log.Logger, dec sdk.TxDecoder, ctx sdk.Context, handler
"error", err,
"msgs", msgTypes(sdkTx),
)
telemetry.IncrCounter(1, "prepare_proposal", "invalid_std_txs")
continue
}
txs[n] = tx
Expand Down Expand Up @@ -83,6 +85,7 @@ func filterBlobTxs(logger log.Logger, dec sdk.TxDecoder, ctx sdk.Context, handle
logger.Error(
"filtering already checked blob transaction", "tx", tmbytes.HexBytes(coretypes.Tx(tx.Tx).Hash()), "error", err,
)
telemetry.IncrCounter(1, "prepare_proposal", "invalid_blob_txs")
continue
}
txs[n] = tx
Expand Down
Loading