Skip to content

Commit

Permalink
feat: add metrics to prepare and process proposal (backport #2560) (#…
Browse files Browse the repository at this point in the history
…2564)

This is an automatic backport of pull request #2560 done by
[Mergify](https://mergify.com).


---


<details>
<summary>Mergify commands and options</summary>

<br />

More conditions and actions can be found in the
[documentation](https://docs.mergify.com/).

You can also trigger Mergify actions by commenting on this pull request:

- `@Mergifyio refresh` will re-evaluate the rules
- `@Mergifyio rebase` will rebase this PR on its base branch
- `@Mergifyio update` will merge the base branch into this PR
- `@Mergifyio backport <destination>` will backport this PR on
`<destination>` branch

Additionally, on Mergify [dashboard](https://dashboard.mergify.com) you
can:

- look at your merge queues
- generate the Mergify configuration with the config editor.

Finally, you can contact us on https://mergify.com
</details>

Co-authored-by: Callum Waters <[email protected]>
  • Loading branch information
mergify[bot] and cmwaters authored Sep 22, 2023
1 parent e08ead2 commit c33a188
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
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

0 comments on commit c33a188

Please sign in to comment.