diff --git a/standard/bridge-v1/cmd/user_cli/main.go b/standard/bridge-v1/cmd/user_cli/main.go index d48f3bc..3c01652 100644 --- a/standard/bridge-v1/cmd/user_cli/main.go +++ b/standard/bridge-v1/cmd/user_cli/main.go @@ -280,6 +280,7 @@ func handlePendingTxes( log.Fatal().Err(err).Msg("failed to check pending transactions") } if !exist { + log.Info().Msg("No pending transactions exist for signing account.") return } if autoCancel { diff --git a/standard/bridge-v1/pkg/shared/tx.go b/standard/bridge-v1/pkg/shared/tx.go index 728db29..6ac57f7 100644 --- a/standard/bridge-v1/pkg/shared/tx.go +++ b/standard/bridge-v1/pkg/shared/tx.go @@ -64,17 +64,31 @@ func BoostTipForTransactOpts( opts *bind.TransactOpts, srcClient *ethclient.Client, ) error { - // Regenerate suggestions from current mempool state - newGasTip, newGasPrice, err := SuggestGasTipCapAndPrice(ctx, srcClient) + log.Debug().Msgf("Gas params for tx that was not included: Gas tip: %s wei, gas fee cap: %s wei, base fee: %s wei", + opts.GasTipCap.String(), opts.GasFeeCap.String(), new(big.Int).Sub(opts.GasFeeCap, opts.GasTipCap).String()) + + newGasTip, newFeeCap, err := SuggestGasTipCapAndPrice(ctx, srcClient) if err != nil { return fmt.Errorf("failed to suggest gas tip cap and price: %w", err) } - newBaseFee := new(big.Int).Sub(newGasPrice, newGasTip) + newBaseFee := new(big.Int).Sub(newFeeCap, newGasTip) if newBaseFee.Cmp(big.NewInt(0)) == -1 { return fmt.Errorf("new base fee cannot be negative: %s", newBaseFee.String()) } + prevBaseFee := new(big.Int).Sub(opts.GasFeeCap, opts.GasTipCap) + if prevBaseFee.Cmp(big.NewInt(0)) == -1 { + return fmt.Errorf("base fee cannot be negative: %s", prevBaseFee.String()) + } + + var maxBaseFee *big.Int + if newBaseFee.Cmp(prevBaseFee) == 1 { + maxBaseFee = newBaseFee + } else { + maxBaseFee = prevBaseFee + } + var maxGasTip *big.Int if newGasTip.Cmp(opts.GasTipCap) == 1 { maxGasTip = newGasTip @@ -82,22 +96,18 @@ func BoostTipForTransactOpts( maxGasTip = opts.GasTipCap } - // Boost tip suggestion by just above 10% for max(new, old) boostedTip := new(big.Int).Add(maxGasTip, new(big.Int).Div(maxGasTip, big.NewInt(10))) boostedTip = boostedTip.Add(boostedTip, big.NewInt(1)) - baseFee := new(big.Int).Sub(opts.GasFeeCap, opts.GasTipCap) - if baseFee.Cmp(big.NewInt(0)) == -1 { - return fmt.Errorf("base fee cannot be negative: %s", baseFee.String()) - } - - log.Debug().Msgf("Gas params for tx that was not included: Gas tip: %s wei, gas fee cap: %s wei, base fee: %s wei", opts.GasTipCap.String(), opts.GasFeeCap.String(), baseFee.String()) - log.Debug().Msg("Tip will be boosted by 10%, base fee will be new suggestion") + boostedBaseFee := new(big.Int).Add(maxBaseFee, new(big.Int).Div(maxBaseFee, big.NewInt(10))) + boostedBaseFee = boostedBaseFee.Add(boostedBaseFee, big.NewInt(1)) opts.GasTipCap = boostedTip - opts.GasFeeCap = new(big.Int).Add(newBaseFee, boostedTip) + opts.GasFeeCap = new(big.Int).Add(boostedBaseFee, boostedTip) - log.Debug().Msgf("Boosted gas tip to %s wei and gas fee cap to %s wei. New base fee: %s wei", opts.GasTipCap.String(), opts.GasFeeCap.String(), newBaseFee.String()) + log.Debug().Msg("Tip and base fee will be boosted by 10%") + log.Debug().Msgf("Boosted gas tip cap to %s wei and gas fee cap to %s wei. Base fee: %s wei", + opts.GasTipCap.String(), opts.GasFeeCap.String(), boostedBaseFee.String()) return nil } @@ -118,7 +128,7 @@ func WaitMinedWithRetry( submitTx TxSubmitFunc, ) (*types.Receipt, error) { - const maxRetries = 5 + const maxRetries = 10 var err error var tx *types.Transaction