Skip to content

Commit

Permalink
fix(relayer): add revert check back in, add gas limit to response (#1…
Browse files Browse the repository at this point in the history
  • Loading branch information
cyberhorsey authored Apr 16, 2024
1 parent e992ec9 commit 324d626
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 3 deletions.
4 changes: 4 additions & 0 deletions packages/relayer/pkg/http/get_recommended_processing_fees.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"math/big"
"net/http"
"strconv"

"github.com/cyberhorsey/webutils"
"github.com/ethereum/go-ethereum/accounts/abi/bind"
Expand All @@ -20,6 +21,7 @@ type fee struct {
Type string `json:"type"`
Amount string `json:"amount"`
DestChainID uint64 `json:"destChainID"`
GasLimit string `json:"gasLimit"`
}

type FeeType uint64
Expand Down Expand Up @@ -122,12 +124,14 @@ func (srv *Server) GetRecommendedProcessingFees(c echo.Context) error {
Type: f.String(),
Amount: srv.getCost(c.Request().Context(), uint64(f), destGasTipCap, destBaseFee, Layer1).String(),
DestChainID: srcChainID.Uint64(),
GasLimit: strconv.Itoa(int(f)),
})

fees = append(fees, fee{
Type: f.String(),
Amount: srv.getCost(c.Request().Context(), uint64(f), srcGasTipCap, srcBaseFee, Layer2).String(),
DestChainID: destChainID.Uint64(),
GasLimit: strconv.Itoa(int(f)),
})
}

Expand Down
2 changes: 2 additions & 0 deletions packages/relayer/processor/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ var (
"Method eth_maxPriorityFeePerGas not found",
)

errTxReverted = errors.New("tx reverted")

// FallbackGasTipCap is the default fallback gasTipCap used when we are
// unable to query an L1 backend for a suggested gasTipCap.
FallbackGasTipCap = big.NewInt(1500000000)
Expand Down
10 changes: 8 additions & 2 deletions packages/relayer/processor/process_message.go
Original file line number Diff line number Diff line change
Expand Up @@ -507,10 +507,16 @@ func (p *Processor) sendProcessMessageCall(
return nil, err
}

relayer.MessageSentEventsProcessed.Inc()

slog.Info("Mined tx", "txHash", hex.EncodeToString(receipt.TxHash.Bytes()))

if receipt.Status != types.ReceiptStatusSuccessful {
relayer.MessageSentEventsProcessedReverted.Inc()

return nil, errTxReverted
}

relayer.MessageSentEventsProcessed.Inc()

if err := p.saveMessageStatusChangedEvent(ctx, receipt, event); err != nil {
return nil, err
}
Expand Down
2 changes: 1 addition & 1 deletion packages/relayer/processor/process_message_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ func Test_sendProcessMessageCall(t *testing.T) {
},
}, []byte{})

assert.Nil(t, err)
assert.Equal(t, err, errTxReverted)
}

func Test_ProcessMessage_messageUnprocessable(t *testing.T) {
Expand Down
4 changes: 4 additions & 0 deletions packages/relayer/prometheus.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ var (
Name: "message_sent_events_processed_ops_total",
Help: "The total number of MessageSent processed events",
})
MessageSentEventsProcessedReverted = promauto.NewCounter(prometheus.CounterOpts{
Name: "message_sent_events_processed_reverted_ops_total",
Help: "The total number of MessageSent processed events that reverted",
})
MessageSentEventsIndexed = promauto.NewCounter(prometheus.CounterOpts{
Name: "message_sent_events_indexed_ops_total",
Help: "The total number of MessageSent indexed events",
Expand Down

0 comments on commit 324d626

Please sign in to comment.