From c51f78dd0105c18670c8c9e6c9fbf8f279cfd26e Mon Sep 17 00:00:00 2001 From: Philip Su Date: Thu, 12 Dec 2024 15:22:32 -0800 Subject: [PATCH] Catch panics on cosmos out of gas in estimateGas --- eth/gasestimator/gasestimator.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/eth/gasestimator/gasestimator.go b/eth/gasestimator/gasestimator.go index 1c19930d81..fa6565d52d 100644 --- a/eth/gasestimator/gasestimator.go +++ b/eth/gasestimator/gasestimator.go @@ -184,9 +184,16 @@ func Estimate(ctx context.Context, call *core.Message, opts *Options, gasCap uin // returns true if the transaction fails for a reason that might be related to // not enough gas. A non-nil error means execution failed due to reasons unrelated // to the gas limit. -func execute(ctx context.Context, call *core.Message, opts *Options, gasLimit uint64) (bool, *core.ExecutionResult, error) { +func execute(ctx context.Context, call *core.Message, opts *Options, gasLimit uint64) (failed bool, execResult *core.ExecutionResult, err error) { // Configure the call for this specific execution (and revert the change after) defer func(gas uint64) { call.GasLimit = gas }(call.GasLimit) + defer func() { + if r := recover(); r != nil { + failed = true + execResult = nil + err = nil + } + }() call.GasLimit = gasLimit // Execute the call and separate execution faults caused by a lack of gas or