diff --git a/integration-tests/actions/seth/actions.go b/integration-tests/actions/seth/actions.go index 12743ce5284..b29314a0850 100644 --- a/integration-tests/actions/seth/actions.go +++ b/integration-tests/actions/seth/actions.go @@ -187,20 +187,27 @@ func SendFunds(logger zerolog.Logger, client *seth.Client, payload FundsToSendPa return nil, err } - gasLimit := uint64(client.Cfg.Network.TransferGasFee) + var gasLimit int64 + gasLimitRaw, err := client.EstimateGasLimitForFundTransfer(fromAddress, payload.ToAddress, payload.Amount) + if err != nil { + gasLimit = client.Cfg.Network.TransferGasFee + } else { + gasLimit = int64(gasLimitRaw) + } + gasPrice := big.NewInt(0) gasFeeCap := big.NewInt(0) gasTipCap := big.NewInt(0) if payload.GasLimit != nil { - gasLimit = uint64(*payload.GasLimit) + gasLimit = *payload.GasLimit } if client.Cfg.Network.EIP1559DynamicFees { // if any of the dynamic fees are not set, we need to either estimate them or read them from config if payload.GasFeeCap == nil || payload.GasTipCap == nil { - // estimatior or config reading happens here - txOptions := client.NewTXOpts(seth.WithGasLimit(gasLimit)) + // estimation or config reading happens here + txOptions := client.NewTXOpts(seth.WithGasLimit(uint64(gasLimit))) gasFeeCap = txOptions.GasFeeCap gasTipCap = txOptions.GasTipCap } @@ -215,7 +222,7 @@ func SendFunds(logger zerolog.Logger, client *seth.Client, payload FundsToSendPa } } else { if payload.GasPrice == nil { - txOptions := client.NewTXOpts((seth.WithGasLimit(gasLimit))) + txOptions := client.NewTXOpts(seth.WithGasLimit(uint64(gasLimit))) gasPrice = txOptions.GasPrice } else { gasPrice = payload.GasPrice @@ -229,7 +236,7 @@ func SendFunds(logger zerolog.Logger, client *seth.Client, payload FundsToSendPa Nonce: nonce, To: &payload.ToAddress, Value: payload.Amount, - Gas: gasLimit, + Gas: uint64(gasLimit), GasFeeCap: gasFeeCap, GasTipCap: gasTipCap, } @@ -238,7 +245,7 @@ func SendFunds(logger zerolog.Logger, client *seth.Client, payload FundsToSendPa Nonce: nonce, To: &payload.ToAddress, Value: payload.Amount, - Gas: gasLimit, + Gas: uint64(gasLimit), GasPrice: gasPrice, } } @@ -259,7 +266,7 @@ func SendFunds(logger zerolog.Logger, client *seth.Client, payload FundsToSendPa Str("To", payload.ToAddress.Hex()). Str("Amount (wei/ether)", fmt.Sprintf("%s/%s", payload.Amount, conversions.WeiToEther(payload.Amount).Text('f', -1))). Uint64("Nonce", nonce). - Uint64("Gas Limit", gasLimit). + Int64("Gas Limit", gasLimit). Str("Gas Price", gasPrice.String()). Str("Gas Fee Cap", gasFeeCap.String()). Str("Gas Tip Cap", gasTipCap.String()). @@ -279,7 +286,7 @@ func SendFunds(logger zerolog.Logger, client *seth.Client, payload FundsToSendPa Str("TxHash", signedTx.Hash().String()). Str("Amount (wei/ether)", fmt.Sprintf("%s/%s", payload.Amount, conversions.WeiToEther(payload.Amount).Text('f', -1))). Uint64("Nonce", nonce). - Uint64("Gas Limit", gasLimit). + Int64("Gas Limit", gasLimit). Str("Gas Price", gasPrice.String()). Str("Gas Fee Cap", gasFeeCap.String()). Str("Gas Tip Cap", gasTipCap.String()). diff --git a/integration-tests/actions/seth/refund.go b/integration-tests/actions/seth/refund.go index 3119083b1b1..75adf95ce8e 100644 --- a/integration-tests/actions/seth/refund.go +++ b/integration-tests/actions/seth/refund.go @@ -262,7 +262,7 @@ func ReturnFundsFromNodes(log zerolog.Logger, client *seth.Client, chainlinkNode return err } - err = sendAllFundsIfPossible(log, client, decryptedKey.PrivateKey) + err = returnAllFundsIfPossible(log, client, decryptedKey.PrivateKey) if err != nil { log.Error().Err(err).Msg("Failed to return funds from Chainlink node to default network wallet") publicKey := decryptedKey.PrivateKey.Public() @@ -284,7 +284,7 @@ func ReturnFundsFromNodes(log zerolog.Logger, client *seth.Client, chainlinkNode return nil } -func sendAllFundsIfPossible(log zerolog.Logger, sethClient *seth.Client, fromPrivateKey *ecdsa.PrivateKey) error { +func returnAllFundsIfPossible(log zerolog.Logger, sethClient *seth.Client, fromPrivateKey *ecdsa.PrivateKey) error { publicKey := fromPrivateKey.Public() publicKeyECDSA, ok := publicKey.(*ecdsa.PublicKey) if !ok { @@ -321,11 +321,19 @@ func sendAllFundsIfPossible(log zerolog.Logger, sethClient *seth.Client, fromPri Priority: txPriority, }) + var gasLimit int64 + gasLimitRaw, err := sethClient.EstimateGasLimitForFundTransfer(fromAddress, sethClient.Addresses[0], balance) + if err != nil { + gasLimit = sethClient.Cfg.Network.TransferGasFee + } else { + gasLimit = int64(gasLimitRaw) + } + var maxTotalGasCost *big.Int if sethClient.Cfg.Network.EIP1559DynamicFees { - maxTotalGasCost = new(big.Int).Mul(big.NewInt(0).SetInt64(sethClient.Cfg.Network.TransferGasFee), estimations.GasFeeCap) + maxTotalGasCost = new(big.Int).Mul(big.NewInt(0).SetInt64(gasLimit), estimations.GasFeeCap) } else { - maxTotalGasCost = new(big.Int).Mul(big.NewInt(0).SetInt64(sethClient.Cfg.Network.TransferGasFee), estimations.GasPrice) + maxTotalGasCost = new(big.Int).Mul(big.NewInt(0).SetInt64(gasLimit), estimations.GasPrice) } toSend := new(big.Int).Sub(balance, maxTotalGasCost) @@ -345,7 +353,7 @@ func sendAllFundsIfPossible(log zerolog.Logger, sethClient *seth.Client, fromPri ToAddress: sethClient.Addresses[0], Amount: toSend, PrivateKey: fromPrivateKey, - GasLimit: &sethClient.Cfg.Network.TransferGasFee, + GasLimit: &gasLimit, GasPrice: estimations.GasPrice, GasFeeCap: estimations.GasFeeCap, GasTipCap: estimations.GasTipCap, @@ -354,7 +362,7 @@ func sendAllFundsIfPossible(log zerolog.Logger, sethClient *seth.Client, fromPri _, err = SendFunds(log, sethClient, payload) if err != nil { - handler := OvershotTransferRetrier{maxRetries: 10, nextRetrier: &InsufficientFundTransferRetrier{maxRetries: 10, nextRetrier: &GasTooLowTransferRetrier{maxGasLimit: sethClient.Cfg.Network.TransferGasFee * 10}}} + handler := OvershotTransferRetrier{maxRetries: 10, nextRetrier: &InsufficientFundTransferRetrier{maxRetries: 10, nextRetrier: &GasTooLowTransferRetrier{maxGasLimit: gasLimit * 10}}} err = handler.Retry(context.Background(), log, sethClient, err, payload, 0) if err != nil { log.Error(). diff --git a/integration-tests/go.mod b/integration-tests/go.mod index ec2ded62c93..baee3cff6b0 100644 --- a/integration-tests/go.mod +++ b/integration-tests/go.mod @@ -32,7 +32,7 @@ require ( github.com/smartcontractkit/chainlink-vrf v0.0.0-20231120191722-fef03814f868 github.com/smartcontractkit/chainlink/v2 v2.0.0-00010101000000-000000000000 github.com/smartcontractkit/libocr v0.0.0-20240419185742-fd3cab206b2c - github.com/smartcontractkit/seth v0.1.7-0.20240506111032-35a1950da7e6 + github.com/smartcontractkit/seth v0.1.7-0.20240506143142-19b341728a52 github.com/smartcontractkit/wasp v0.4.7 github.com/spf13/cobra v1.8.0 github.com/stretchr/testify v1.9.0 diff --git a/integration-tests/go.sum b/integration-tests/go.sum index 7e57e196d7e..ea99c3cb573 100644 --- a/integration-tests/go.sum +++ b/integration-tests/go.sum @@ -1535,8 +1535,8 @@ github.com/smartcontractkit/grpc-proxy v0.0.0-20230731113816-f1be6620749f h1:hgJ github.com/smartcontractkit/grpc-proxy v0.0.0-20230731113816-f1be6620749f/go.mod h1:MvMXoufZAtqExNexqi4cjrNYE9MefKddKylxjS+//n0= github.com/smartcontractkit/libocr v0.0.0-20240419185742-fd3cab206b2c h1:lIyMbTaF2H0Q71vkwZHX/Ew4KF2BxiKhqEXwF8rn+KI= github.com/smartcontractkit/libocr v0.0.0-20240419185742-fd3cab206b2c/go.mod h1:fb1ZDVXACvu4frX3APHZaEBp0xi1DIm34DcA0CwTsZM= -github.com/smartcontractkit/seth v0.1.7-0.20240506111032-35a1950da7e6 h1:etn6EfK8AllunLRr0y6fyYgv10/cUaW5tcBzLnTIy3g= -github.com/smartcontractkit/seth v0.1.7-0.20240506111032-35a1950da7e6/go.mod h1:2TMOZQ8WTAw7rR1YBbXpnad6VmT/+xDd/nXLmB7Eero= +github.com/smartcontractkit/seth v0.1.7-0.20240506143142-19b341728a52 h1:SGOACHnCChcNd4ADj4/f8rWxr3ELFKP+ba9lgFIh24Q= +github.com/smartcontractkit/seth v0.1.7-0.20240506143142-19b341728a52/go.mod h1:2TMOZQ8WTAw7rR1YBbXpnad6VmT/+xDd/nXLmB7Eero= github.com/smartcontractkit/tdh2/go/ocr2/decryptionplugin v0.0.0-20230906073235-9e478e5e19f1 h1:yiKnypAqP8l0OX0P3klzZ7SCcBUxy5KqTAKZmQOvSQE= github.com/smartcontractkit/tdh2/go/ocr2/decryptionplugin v0.0.0-20230906073235-9e478e5e19f1/go.mod h1:q6f4fe39oZPdsh1i57WznEZgxd8siidMaSFq3wdPmVg= github.com/smartcontractkit/tdh2/go/tdh2 v0.0.0-20230906073235-9e478e5e19f1 h1:Dai1bn+Q5cpeGMQwRdjOdVjG8mmFFROVkSKuUgBErRQ= diff --git a/integration-tests/load/go.mod b/integration-tests/load/go.mod index 775fffd97f9..2ddea8dad8d 100644 --- a/integration-tests/load/go.mod +++ b/integration-tests/load/go.mod @@ -21,7 +21,7 @@ require ( github.com/smartcontractkit/chainlink/integration-tests v0.0.0-20240214231432-4ad5eb95178c github.com/smartcontractkit/chainlink/v2 v2.9.0-beta0.0.20240216210048-da02459ddad8 github.com/smartcontractkit/libocr v0.0.0-20240419185742-fd3cab206b2c - github.com/smartcontractkit/seth v0.1.7-0.20240506111032-35a1950da7e6 + github.com/smartcontractkit/seth v0.1.7-0.20240506143142-19b341728a52 github.com/smartcontractkit/tdh2/go/tdh2 v0.0.0-20230906073235-9e478e5e19f1 github.com/smartcontractkit/wasp v0.4.7 github.com/stretchr/testify v1.9.0 diff --git a/integration-tests/load/go.sum b/integration-tests/load/go.sum index 7f61214c669..e66b5f19abc 100644 --- a/integration-tests/load/go.sum +++ b/integration-tests/load/go.sum @@ -1526,8 +1526,8 @@ github.com/smartcontractkit/grpc-proxy v0.0.0-20230731113816-f1be6620749f h1:hgJ github.com/smartcontractkit/grpc-proxy v0.0.0-20230731113816-f1be6620749f/go.mod h1:MvMXoufZAtqExNexqi4cjrNYE9MefKddKylxjS+//n0= github.com/smartcontractkit/libocr v0.0.0-20240419185742-fd3cab206b2c h1:lIyMbTaF2H0Q71vkwZHX/Ew4KF2BxiKhqEXwF8rn+KI= github.com/smartcontractkit/libocr v0.0.0-20240419185742-fd3cab206b2c/go.mod h1:fb1ZDVXACvu4frX3APHZaEBp0xi1DIm34DcA0CwTsZM= -github.com/smartcontractkit/seth v0.1.7-0.20240506111032-35a1950da7e6 h1:etn6EfK8AllunLRr0y6fyYgv10/cUaW5tcBzLnTIy3g= -github.com/smartcontractkit/seth v0.1.7-0.20240506111032-35a1950da7e6/go.mod h1:2TMOZQ8WTAw7rR1YBbXpnad6VmT/+xDd/nXLmB7Eero= +github.com/smartcontractkit/seth v0.1.7-0.20240506143142-19b341728a52 h1:SGOACHnCChcNd4ADj4/f8rWxr3ELFKP+ba9lgFIh24Q= +github.com/smartcontractkit/seth v0.1.7-0.20240506143142-19b341728a52/go.mod h1:2TMOZQ8WTAw7rR1YBbXpnad6VmT/+xDd/nXLmB7Eero= github.com/smartcontractkit/tdh2/go/ocr2/decryptionplugin v0.0.0-20230906073235-9e478e5e19f1 h1:yiKnypAqP8l0OX0P3klzZ7SCcBUxy5KqTAKZmQOvSQE= github.com/smartcontractkit/tdh2/go/ocr2/decryptionplugin v0.0.0-20230906073235-9e478e5e19f1/go.mod h1:q6f4fe39oZPdsh1i57WznEZgxd8siidMaSFq3wdPmVg= github.com/smartcontractkit/tdh2/go/tdh2 v0.0.0-20230906073235-9e478e5e19f1 h1:Dai1bn+Q5cpeGMQwRdjOdVjG8mmFFROVkSKuUgBErRQ= diff --git a/integration-tests/wrappers/contract_caller.go b/integration-tests/wrappers/contract_caller.go index 952fe79c941..0eea760e024 100644 --- a/integration-tests/wrappers/contract_caller.go +++ b/integration-tests/wrappers/contract_caller.go @@ -282,9 +282,6 @@ func (w *WrappedContractBackend) getErrorFromContext(ctx context.Context) error if v, ok := ctxErr.(error); ok { return v } - if v, ok := ctxErr.(seth.ContextErrorValue); ok { - return v.Error - } return errors.Wrapf(errors.New("unknown error type"), "error in context: %v", ctxErr) }