From 76a669af09880bdab42603995b5868248c767b58 Mon Sep 17 00:00:00 2001 From: blockchainluffy Date: Fri, 13 Jun 2025 16:08:26 +0530 Subject: [PATCH 1/3] fix: Min1GweiGasPriceFn to include GweiGasTip with gasFeeCap --- utils/utils.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/utils/utils.go b/utils/utils.go index 2dbb0d8..676d86b 100644 --- a/utils/utils.go +++ b/utils/utils.go @@ -151,7 +151,7 @@ func Min1GweiGasPriceFn(suggestedGasTipCap *big.Int, suggestedGasPrice *big.Int, GweiGasTip := big.NewInt(1_000_000_000) if gasTipCap.Cmp(GweiGasTip) < 0 { - return gasFeeCap, GweiGasTip + return big.NewInt(0).Add(GweiGasTip, gasFeeCap), GweiGasTip } return gasFeeCap, gasTipCap } From e2016911a07ce91ed46b5dd83ce8e09292714d6c Mon Sep 17 00:00:00 2001 From: blockchainluffy Date: Fri, 13 Jun 2025 18:02:48 +0530 Subject: [PATCH 2/3] chore: add MIN_GAS_TIP_CAP as env --- template.env | 1 + utils/utils.go | 10 +++++++++- 2 files changed, 10 insertions(+), 1 deletion(-) 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 676d86b..67639fd 100644 --- a/utils/utils.go +++ b/utils/utils.go @@ -149,7 +149,15 @@ func HighPriorityGasPriceFn(suggestedGasTipCap *big.Int, suggestedGasPrice *big. func Min1GweiGasPriceFn(suggestedGasTipCap *big.Int, suggestedGasPrice *big.Int, _ int, _ int) (GasFeeCap, GasTipCap) { gasFeeCap, gasTipCap := DefaultGasPriceFn(suggestedGasTipCap, suggestedGasPrice, 0, 1) - GweiGasTip := big.NewInt(1_000_000_000) + 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 gasTipCap.Cmp(GweiGasTip) < 0 { return big.NewInt(0).Add(GweiGasTip, gasFeeCap), GweiGasTip } From 81b45521b1da329feb86b3d5dd757a00632374ea Mon Sep 17 00:00:00 2001 From: blockchainluffy Date: Mon, 16 Jun 2025 13:06:30 +0530 Subject: [PATCH 3/3] fix: min gas tip fn --- continuous/tx.go | 2 +- utils/utils.go | 9 ++++----- 2 files changed, 5 insertions(+), 6 deletions(-) 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/utils/utils.go b/utils/utils.go index 67639fd..3bc8ddb 100644 --- a/utils/utils.go +++ b/utils/utils.go @@ -146,8 +146,7 @@ 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) // 1 Gwei if minGasTipCap := os.Getenv("MIN_GAS_TIP_CAP"); minGasTipCap != "" { @@ -158,10 +157,10 @@ func Min1GweiGasPriceFn(suggestedGasTipCap *big.Int, suggestedGasPrice *big.Int, GweiGasTip = big.NewInt(int64(minGasTip)) } } - if gasTipCap.Cmp(GweiGasTip) < 0 { - return big.NewInt(0).Add(GweiGasTip, gasFeeCap), GweiGasTip + 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