-
Notifications
You must be signed in to change notification settings - Fork 58
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(monitor): monitor omni EVM gas tip cap (#2590)
Monitor omni evm gas tip cap. issue: #2200
- Loading branch information
1 parent
dffc7bf
commit a16e2fc
Showing
3 changed files
with
52 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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())) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters