diff --git a/continuous/tx.go b/continuous/tx.go index 8dbcf20..bd2a610 100644 --- a/continuous/tx.go +++ b/continuous/tx.go @@ -90,7 +90,7 @@ func SendShutterizedTX(blockNumber int64, lastTimestamp pgtype.Date, cfg *Config log.Printf("SENDING NEW TX FOR %v from %v", blockNumber, account.Address.Hex()) gasLimit := uint64(21000) var data []byte - gas, err := utils.GasCalculationFromClient(context.Background(), cfg.client, utils.Min1GweiGasPriceFn) + gas, err := utils.GasCalculationFromClient(context.Background(), cfg.client, utils.MinGasTipUpdateFn) if err != nil { panic(err) } diff --git a/template.env b/template.env index 9aeec46..7ae482d 100644 --- a/template.env +++ b/template.env @@ -1,6 +1,7 @@ ## TEMPLATE ONLY PRIVATE_KEY="YOUR_PRIVATE_KEY" MODE="chiado" +MIN_GAS_TIP_CAP=900000 #CHIADO TEST CHIADO_URL="https://erpc.chiado.staging.shutter.network" diff --git a/utils/utils.go b/utils/utils.go index 2dbb0d8..3bc8ddb 100644 --- a/utils/utils.go +++ b/utils/utils.go @@ -146,14 +146,21 @@ func HighPriorityGasPriceFn(suggestedGasTipCap *big.Int, suggestedGasPrice *big. return gasFeeCap, suggestedGasTipCap } -func Min1GweiGasPriceFn(suggestedGasTipCap *big.Int, suggestedGasPrice *big.Int, _ int, _ int) (GasFeeCap, GasTipCap) { - gasFeeCap, gasTipCap := DefaultGasPriceFn(suggestedGasTipCap, suggestedGasPrice, 0, 1) +func MinGasTipUpdateFn(suggestedGasTipCap *big.Int, suggestedGasPrice *big.Int, _ int, _ int) (GasFeeCap, GasTipCap) { - GweiGasTip := big.NewInt(1_000_000_000) - if gasTipCap.Cmp(GweiGasTip) < 0 { - return gasFeeCap, GweiGasTip + GweiGasTip := big.NewInt(1_000_000_000) // 1 Gwei + if minGasTipCap := os.Getenv("MIN_GAS_TIP_CAP"); minGasTipCap != "" { + minGasTip, err := strconv.Atoi(minGasTipCap) + if err != nil { + log.Println("could not parse MIN_GAS_TIP_CAP, using default 1 Gwei") + } else { + GweiGasTip = big.NewInt(int64(minGasTip)) + } + } + if suggestedGasTipCap.Cmp(GweiGasTip) < 0 { + return big.NewInt(0).Add(GweiGasTip, suggestedGasPrice), GweiGasTip } - return gasFeeCap, gasTipCap + return suggestedGasPrice, suggestedGasTipCap } type ConstraintFn func(inclusions []*types.Receipt) error