Skip to content

Commit

Permalink
chore(monitor): monitor omni EVM gas tip cap (#2590)
Browse files Browse the repository at this point in the history
Monitor omni evm gas tip cap.

issue: #2200
  • Loading branch information
corverroos authored Nov 29, 2024
1 parent dffc7bf commit a16e2fc
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 0 deletions.
1 change: 1 addition & 0 deletions monitor/app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ func Run(ctx context.Context, cfg Config) error {
go routerecon.ReconForever(ctx, network, xprov, ethClients)
go validator.MonitorForever(ctx, cprov)
go monitorPublicRPCForever(ctx, network, ethClients)
go monitorOmniEVMGasTipForever(ctx, network, ethClients)

select {
case <-ctx.Done():
Expand Down
44 changes: 44 additions & 0 deletions monitor/app/gastip.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package monitor

import (
"context"
"math/big"
"time"

"github.com/omni-network/omni/lib/ethclient"
"github.com/omni-network/omni/lib/log"
"github.com/omni-network/omni/lib/netconf"

"github.com/ethereum/go-ethereum/params"
)

// monitorOmniEVMGasTipForever monitors the suggested gas tip cap for the Omni EVM chain.
func monitorOmniEVMGasTipForever(ctx context.Context,
network netconf.Network,
ethClients map[uint64]ethclient.Client,
) {
ethCl, ok := ethClients[network.ID.Static().OmniExecutionChainID]
if !ok {
log.Error(ctx, "No eth client for omni chain", nil)
return
}

ticker := time.NewTicker(time.Second * 30)
defer ticker.Stop()

for {
select {
case <-ctx.Done():
return
case <-ticker.C:
tip, err := ethCl.SuggestGasTipCap(ctx)
if err != nil {
log.Warn(ctx, "Failed to get gas tip (will retry)", err)
continue
}

tipGwei := new(big.Int).Div(tip, big.NewInt(params.GWei))
gasTipCap.Set(float64(tipGwei.Uint64()))
}
}
}
7 changes: 7 additions & 0 deletions monitor/app/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,11 @@ var (
Name: "sync_diff",
Help: "Sync difference (highest blocks) betweent public RPC and omni node",
})

gasTipCap = promauto.NewGauge(prometheus.GaugeOpts{
Namespace: "monitor",
Subsystem: "omni_evm",
Name: "gas_tip_cap_gwei",
Help: "Suggested OmniEVM gas tip cap in gwei",
})
)

0 comments on commit a16e2fc

Please sign in to comment.