From 16ff335b1686ad620c6dd3c14506d53872df21bd Mon Sep 17 00:00:00 2001 From: Michael Zhou Date: Mon, 11 Apr 2022 04:32:09 +0800 Subject: [PATCH] Allow setting gasPrice smaller than suggested (#56) --- eth/transactor.go | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/eth/transactor.go b/eth/transactor.go index d54c6d5..a67fdb4 100644 --- a/eth/transactor.go +++ b/eth/transactor.go @@ -26,7 +26,6 @@ const ( ) var ( - ErrExceedMaxGas = errors.New("suggested gas price exceeds max allowed") ErrConflictingGasFlags = errors.New("cannot specify both legacy and EIP-1559 gas flags") ctxTimeout = 10 * time.Second @@ -292,10 +291,10 @@ func determineLegacyGasPrice( } if txopts.maxGasGwei > 0 { // maxGas 0 means no cap on gas price maxPrice := new(big.Int).SetUint64(txopts.maxGasGwei * 1e9) - // GasPrice is larger than allowed cap, return error + // GasPrice is larger than allowed cap, use maxPrice but log warning if maxPrice.Cmp(gasPrice) < 0 { log.Warnf("suggested gas price %s larger than cap %s", gasPrice, maxPrice) - return ErrExceedMaxGas + gasPrice = maxPrice } } signer.GasPrice = gasPrice