Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion continuous/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
1 change: 1 addition & 0 deletions template.env
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
19 changes: 13 additions & 6 deletions utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The fee calculation still needs an adjustment to ensure we don't run into fee too low errors:

  1. maxFeePerGas is currently derived from SuggestGasPrice (legacy). That can under‑estimate the base fee at inclusion time and trigger “fee too low.” We should derive maxFeePerGas from the current block baseFee and add a buffer for the next N blocks (N configurable with a high upper-bound for simplicity or based on target slot).

  2. The previous function enforced a minimum priority fee of 1 gwei. The updated approach does not take into account the suggested gas tip and rather enforces a maximum of 1gwei. My previous suggestion was to set a configuredMinTip (no hardcoded 1 gwei), so we still take into account the suggestGasTip (which is not the case here anymore). In addition, we should make sure maxFeePerGas >= maxPriorityFeePerGas otherwise the transaction is invalid.


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
Expand Down