Skip to content

Commit

Permalink
fix: as comment
Browse files Browse the repository at this point in the history
  • Loading branch information
Benzbeeb committed Feb 17, 2025
1 parent 44d624b commit e8073e4
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 10 deletions.
7 changes: 6 additions & 1 deletion node/block_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,13 @@ func (n *Node) handleEndBlock(ctx types.Context, blockID []byte, protoBlock *pro
}

// handleRawBlock handles the raw block bytes.
func (n *Node) handleRawBlock(ctx types.Context, blockHeight int64, latestHeight int64, blockBytes []byte) error {
func (n *Node) handleRawBlock(parentCtx types.Context, blockHeight int64, latestHeight int64, blockBytes []byte) error {
if n.rawBlockHandler != nil {
transactions, ctx := sentry_integration.StartSentryTransaction(parentCtx, "handleRawBlock", "Handles the raw block bytes")
defer transactions.Finish()
transactions.SetTag("height", fmt.Sprintf("%d", blockHeight))
transactions.SetTag("latest_height", fmt.Sprintf("%d", latestHeight))

return n.rawBlockHandler(ctx, nodetypes.RawBlockArgs{
BlockHeight: blockHeight,
LatestHeight: latestHeight,
Expand Down
17 changes: 8 additions & 9 deletions node/broadcaster/account.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"fmt"
"math"
"strings"

abci "github.com/cometbft/cometbft/abci/types"
"github.com/getsentry/sentry-go"
Expand All @@ -21,7 +22,7 @@ import (
"github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/crypto/keyring"
sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"

txtypes "github.com/cosmos/cosmos-sdk/types/tx"
"github.com/cosmos/cosmos-sdk/types/tx/signing"
authsigning "github.com/cosmos/cosmos-sdk/x/auth/signing"
Expand Down Expand Up @@ -224,15 +225,13 @@ func (b BroadcasterAccount) CalculateGas(ctx context.Context, msgs ...sdk.Msg) (

res, err := b.rpcClient.QueryABCI(ctx, simQuery)
if err != nil {
switch {
case sdkerrors.ErrOutOfGas.Is(err):
sentry_integration.CaptureCurrentHubException(err, sentry.LevelError)
return txtypes.SimulateResponse{}, 0, err

case sdkerrors.ErrInsufficientFee.Is(err):
sentry_integration.CaptureCurrentHubException(err, sentry.LevelError)
return txtypes.SimulateResponse{}, 0, err
for _, e := range sentryCapturedErrors {
if strings.Contains(err.Error(), e.Error()) {
sentry_integration.CaptureCurrentHubException(err, sentry.LevelError)
return txtypes.SimulateResponse{}, 0, err
}
}

return txtypes.SimulateResponse{}, 0, err
}

Expand Down
13 changes: 13 additions & 0 deletions node/broadcaster/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (
"github.com/initia-labs/opinit-bots/sentry_integration"
"github.com/initia-labs/opinit-bots/types"

sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
opchildtypes "github.com/initia-labs/OPinit/x/opchild/types"
)

Expand All @@ -27,6 +28,11 @@ var ignoringErrors = []error{
var accountSeqRegex = regexp.MustCompile("account sequence mismatch, expected ([0-9]+), got ([0-9]+)")
var outputIndexRegex = regexp.MustCompile("expected ([0-9]+), got ([0-9]+): invalid output index")

var sentryCapturedErrors = []error{
sdkerrors.ErrOutOfGas,
sdkerrors.ErrInsufficientFunds,
}

// handleMsgError handles error when processing messages.
// If there is an error known to be ignored, it will be ignored.
func (b *Broadcaster) handleMsgError(ctx types.Context, err error, broadcasterAccount *BroadcasterAccount) error {
Expand Down Expand Up @@ -65,6 +71,13 @@ func (b *Broadcaster) handleMsgError(ctx types.Context, err error, broadcasterAc
return err
}

for _, e := range sentryCapturedErrors {
if strings.Contains(err.Error(), e.Error()) {
sentry_integration.CaptureCurrentHubException(err, sentry.LevelError)
return err
}
}

for _, e := range ignoringErrors {
if strings.Contains(err.Error(), e.Error()) {
ctx.Logger().Warn("ignoring error", zap.String("error", e.Error()))
Expand Down
4 changes: 4 additions & 0 deletions node/process.go
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,10 @@ func (n *Node) handleEvent(ctx types.Context, blockHeight int64, blockTime time.
if n.eventHandlers[event.GetType()] == nil {
return nil
}
span, ctx := sentry_integration.StartSentrySpan(ctx, "handleEvent", "Handles the event for the given transaction")
defer span.Finish()
span.SetTag("height", fmt.Sprintf("%d", blockHeight))
span.SetTag("type", event.GetType())

ctx.Logger().Debug("handle event", zap.Int64("height", blockHeight), zap.String("type", event.GetType()))
return n.eventHandlers[event.Type](ctx, nodetypes.EventHandlerArgs{
Expand Down

0 comments on commit e8073e4

Please sign in to comment.