ethers-io / ethers.js

Complete Ethereum library and wallet implementation in JavaScript.
https://ethers.org/
MIT License
8k stars 1.86k forks source link

UNPREDICTABLE_GAS_LIMIT error w/ execution reverted for valid transaction on arbitrum-goerli chain #4041

Open riordant opened 1 year ago

riordant commented 1 year ago

Ethers Version

5.7.1

Search Terms

No response

Describe the Problem

Hi, we are getting strange issues with sending transactions through Ethers on the arbitrum-goerli test chain. It only seems to occur when there is a gas spike. The transaction that we attempt to send is a valid state change (verified by executing on a fork from the same block afterwords) but when trying to send, it fails. we believe it is related to gas estimation in Ethers (v5). any help would be appreciated. thanks.

Code Snippet

async getTradeManagerOrdersWithSigner() {
        let wallet = this.getSigner().connect(this.chainProvider.getProvider());
        return this._tradeManagerWithSigner.connect(wallet);
    }

const contractWithExecutor = await this.executorProvider.getTradeManagerOrdersWithSigner()
const transaction = await contractWithExecutor[method](
            orderStruct,
            order.updateData,
            order.maker,
            order.signature
);

Contract ABI

No response

Errors

Transaction failed {"error":{"code":"UNPREDICTABLE_GAS_LIMIT","error":{"code":"UNPREDICTABLE_GAS_LIMIT","error":{"body":"{\"jsonrpc\":\"2.0\",\"id\":3734,\"error\":{\"code\":-32000,\"message\":\"execution reverted\"}}\n","code":"SERVER_ERROR","error":{"code":-32000},"reason":"processing response error","requestBody":"{\"method\":\"eth_estimateGas\",\"params\":[{\"type\":\"0x2\",\"maxFeePerGas\":\"0x435b41fca0\",\"maxPriorityFeePerGas\":\"0x59682f00\",\"from\":\"0x5b7d1dea9d55dfe69e42f3129a5523c4ad1c035b\",\"to\":\"0x6ece90a0882838c2c1cba1fedc27fafb17547ac3\",\"data\":\"0xe5fb37f5000000000000000000000000be2dc0f04bd8bf8700c821f6f0b6924dd27dc54600000000000000000000000000000000000000000000000000000000009896800000000000000000000000000000000000000000000000000000000004f27ac000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000645e27fa0000000000000000000000000000000000000000550de187206aa7407ce0dc000000000000000000000000000000000000000000553978ea0e498db471da640000000000000000000000000000000000000000000000000000000000645e27be00000000000000000000000000000000000000000000000000000000000001a00000000000000000000000002abb6c4a092616acb3116cfe920f27c30a26c4800000000000000000000000000000000000000000000000000000000000000320000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000200000000000000000000000000333c3cdf15a2d8e14a1f9db9d76e8bcad52c5e5000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000c18f99a5d4309aed805d34931a782c4642d4b84122f582aebfb7a3bd77252bb95a1b1485336b4ae3faab42a642ca64d7f37ab1b15609750f0d35d5177bc86bdde71b0000000000000000000000003a4da92ff4779394051ca07c9f0463bc1a0953e100000000000000000000000000000000000000000000000000000000645e27c300000000000000000000000000000000000000000000000000000000645e283b00000000000000000000000000000000000000005524be1948dc7a063a5e200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004117dbbdd489ed806f43c5bf0fe6651632367b0aaf07ea94702f4ce8673e59ef8a4cba2e1b9dafd0d4c0fca05193aa13650df9d6ccd9db85c5fd7ad9e918c93a6c1c00000000000000000000000000000000000000000000000000000000000000\"}],\"id\":3734,\"jsonrpc\":\"2.0\"}","requestMethod":"POST:},"method":"estimateGas","reason":"execution reverted","transaction":{"accessList":null,"data":"0xe5fb37f5000000000000000000000000be2dc0f04bd8bf8700c821f6f0b6924dd27dc54600000000000000000000000000000000000000000000000000000000009896800000000000000000000000000000000000000000000000000000000004f27ac000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000645e27fa0000000000000000000000000000000000000000550de187206aa7407ce0dc000000000000000000000000000000000000000000553978ea0e498db471da640000000000000000000000000000000000000000000000000000000000645e27be00000000000000000000000000000000000000000000000000000000000001a00000000000000000000000002abb6c4a092616acb3116cfe920f27c30a26c4800000000000000000000000000000000000000000000000000000000000000320000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000200000000000000000000000000333c3cdf15a2d8e14a1f9db9d76e8bcad52c5e5000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000c18f99a5d4309aed805d34931a782c4642d4b84122f582aebfb7a3bd77252bb95a1b1485336b4ae3faab42a642ca64d7f37ab1b15609750f0d35d5177bc86bdde71b0000000000000000000000003a4da92ff4779394051ca07c9f0463bc1a0953e100000000000000000000000000000000000000000000000000000000645e27c300000000000000000000000000000000000000000000000000000000645e283b00000000000000000000000000000000000000005524be1948dc7a063a5e200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004117dbbdd489ed806f43c5bf0fe6651632367b0aaf07ea94702f4ce8673e59ef8a4cba2e1b9dafd0d4c0fca05193aa13650df9d6ccd9db85c5fd7ad9e918c93a6c1c00000000000000000000000000000000000000000000000000000000000000","from":"0x5b7d1DEa9D55dfE69E42f3129a5523c4ad1C035B","maxFeePerGas":{"hex":"0x435b41fca0","type":"BigNumber"},"maxPriorityFeePerGas":{"hex":"0x59682f00","type":"BigNumber"},"to":"0x6EcE90a0882838C2C1Cba1FeDc27fafB17547AC3","type":2}},"reason":"cannot estimate gas; transaction may fail or may require manual gas limit","tx":{"chainId":{},"data":"0xe5fb37f5000000000000000000000000be2dc0f04bd8bf8700c821f6f0b6924dd27dc54600000000000000000000000000000000000000000000000000000000009896800000000000000000000000000000000000000000000000000000000004f27ac000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000645e27fa0000000000000000000000000000000000000000550de187206aa7407ce0dc000000000000000000000000000000000000000000553978ea0e498db471da640000000000000000000000000000000000000000000000000000000000645e27be00000000000000000000000000000000000000000000000000000000000001a00000000000000000000000002abb6c4a092616acb3116cfe920f27c30a26c4800000000000000000000000000000000000000000000000000000000000000320000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000200000000000000000000000000333c3cdf15a2d8e14a1f9db9d76e8bcad52c5e5000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000c18f99a5d4309aed805d34931a782c4642d4b84122f582aebfb7a3bd77252bb95a1b1485336b4ae3faab42a642ca64d7f37ab1b15609750f0d35d5177bc86bdde71b0000000000000000000000003a4da92ff4779394051ca07c9f0463bc1a0953e100000000000000000000000000000000000000000000000000000000645e27c300000000000000000000000000000000000000000000000000000000645e283b00000000000000000000000000000000000000005524be1948dc7a063a5e200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004117dbbdd489ed806f43c5bf0fe6651632367b0aaf07ea94702f4ce8673e59ef8a4cba2e1b9dafd0d4c0fca05193aa13650df9d6ccd9db85c5fd7ad9e918c93a6c1c00000000000000000000000000000000000000000000000000000000000000","from":"0x5b7d1DEa9D55dfE69E42f3129a5523c4ad1C035B","gasLimit":{},"maxFeePerGas":{"hex":"0x435b41fca0","type":"BigNumber"},"maxPriorityFeePerGas":{"hex":"0x59682f00","type":"BigNumber"},"nonce":{},"to":{},"type":2}},"name":"executor","service":"Executor","timestamp":"2023-05-12T11:49:25.270Z"}

Environment

Arbitrum-Goerli

zemse commented 1 year ago

The transaction that we attempt to send is a valid state change (verified by executing on a fork from the same block afterwords) but when trying to send, it fails.

The actual error is execution reverted it's a bit further. How do you get the exact block number on which the estimation was run, since it's not available in the error? Block time on arbitrum goerli is fast so if your block number is approximate still it may have worked for you but on actual one it must be failing.

For debugging, if you can find a block number when it fails otherwise you can just hardcode a gasLimit, so that whenever if it fails it will send a failed tx. Then you can use any of online tools like tenderly to debug the actual cause of the revert on that tx.