Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SERVER_ERROR and INVALID_ARGUMENT errors for version 5.4.1 #1766

Closed
chaitanya5 opened this issue Jul 11, 2021 · 41 comments
Closed

SERVER_ERROR and INVALID_ARGUMENT errors for version 5.4.1 #1766

chaitanya5 opened this issue Jul 11, 2021 · 41 comments
Labels
bug Verified to be an issue. fixed/complete This Bug is fixed or Enhancement is complete and published.

Comments

@chaitanya5
Copy link

chaitanya5 commented Jul 11, 2021

but the same code works fine with ethers version 5.3.1

The code

const provider = new ethers.providers.JsonRpcProvider('https://kovan.infura.io/v3/37d...');
const providerContract = new ethers.Contract(contractAddress, abi, provider);

const wallet = new ethers.Wallet('1234....')
const providerWallet = wallet.connect(provider)
const signerContract = providerContract.connect(providerWallet);

let txHash = await signerContract['safeTransferFrom(address,address,uint256)'](from, to, tokenId, { gasPrice: ethers.utils.parseUnits(30, "gwei") })
await txHash.wait()
@chaitanya5 chaitanya5 added the investigate Under investigation and may be a bug. label Jul 11, 2021
@lcswillems
Copy link

What is the error you get?

@NIC619
Copy link

NIC619 commented Jul 13, 2021

Same here. Works for 5.3.1 but failed with 5.4.1

Error message I got:

Error: cannot estimate gas; transaction may fail or may require manual gas limit (error={
"reason":"processing response error",
"code":"SERVER_ERROR",
"body":"{\"jsonrpc\": \"2.0\", \"error\": {\"code\": -32602, \"message\": \"Invalid params\"}, \"id\": 51}",
"error":{"code":-32602},
"requestBody":"{\"method\":\"eth_estimateGas\",\"params\": BLABLABLA, ... code=UNPREDICTABLE_GAS_LIMIT, 
version=abstract-signer/5.4.0)

@grepfruit19
Copy link

I'm running into a similar problem, seems likely the same one, though I am running into this problem even on version 5.3.1

Here is my code snippet:

    const provider = new ethers.providers.InfuraProvider('rinkeby', apiKey);
    const wallet = new ethers.Wallet(privateKey, provider);
safeService.getTransaction('0xfb0847e5ed1c9421bc853ca7bc2d612d9aa08d055e28b7b5c3b1ae46d5f6e2b8');

    // This call fails with the below error
    const safeContract = new ethers.Contract(safeAddress, GnosisSafe.abi, wallet);
    
    const txResult = await safeContract.execTransaction(
        data.to,
        data.value,
        data.data ? data.data : '',
        data.operation,
        data.safeTxGas,
        data.baseGas,
        data.gasPrice,
        data.gasToken,
        data.refundReceiver,
        signatures,
    );
    console.log('txResult', txResult);
    return res.status(200).json({});

This is the error that I get

Error: invalid ENS name (argument="name", value=undefined, code=INVALID_ARGUMENT, version=providers/5.3.1)
    at Logger.makeError (/Users/Documents/web/node_modules/@ethersproject/logger/lib/index.js:187:21)
    at Logger.throwError (/Users/Documents/web/node_modules/@ethersproject/logger/lib/index.js:196:20)
    at Logger.throwArgumentError (/Users/Documents/web/node_modules/@ethersproject/logger/lib/index.js:199:21)
    at InfuraProvider.<anonymous> (/Users/Documents/web/node_modules/@ethersproject/providers/lib/base-provider.js:1823:36)

  reason: 'invalid ENS name',
  code: 'INVALID_ARGUMENT',
  argument: 'name',
  value: undefined
}

@NIC619
Copy link

NIC619 commented Jul 14, 2021

Since Kovan hasn't been upgraded to support 1559, it looks like Kovan developers won't be able to use ethersjs versions that support 1559 until Kovan is upgraded. Otherwise endpoints like Alchemy or infura will not recognize the new transaction format.

5.4.1 works with Goerli. But Alchemy Goerli hasn't support 1559 atm from what I can tell, only Infura does.

@grepfruit19
Copy link

Never mind, my problem was unrelated. I got the "invalid ENS name" because I passed in the wrong data type.

@laizy
Copy link

laizy commented Jul 15, 2021

We have this problem too, and find out it is caused by wrong arrayify implementation when the first arg's type is Uint8Array.
it will convert it to hex string without '0x' prefix at https://github.com/ethers-io/ethers.js/blob/master/packages/bytes/src.ts/index.ts#L110
and then skipped the following if (isHexString(value)) check.

it can be triggered by call getAddress:

getAddress("0x8ba1f109551bd432803012645ac136ddd64dba72")
-> getChecksumAddress("0x8ba1f109551bd432803012645ac136ddd64dba72")
-> keccak256(Uint8Array) 
-> arrayify(value: Uint8Array)
-> value = value.toHexString() // value does not have 0x prefix

@prestwich
Copy link

@ricmoo breaking support for pre-1559 networks is a backwards incompatible change. v5.4.1 should be v6.0.0

@prestwich
Copy link

prestwich commented Jul 15, 2021

hmmm looking at this more, it may be an unintentional breaking change. I think there are a few problems

  1. in my project we set gasPrice explicitly, but not gas limit. this is causing a block deserialization issue here, as the gas estimator appears to call getBlock somewhere and expects to receive the new format

  2. tx.type inference defaults to 1559 regardless of whether it is supported here. This seems like intentional backwards incompatibility?

  3. tx.type should be inferred here. it should default to 0 unless an eip1559 property is explicitly set (or the version should be 6.0.0)

  4. getFeeData (the eth_feeHistory rpc I assume?) called here is not available on kovan or other chains

@prestwich
Copy link

prestwich commented Jul 15, 2021

for anyone wondering the workaround we're using is:

  1. set tx.type to 0 manually
  2. set tx.gasLimit (and just do without estimation)

@zemse
Copy link
Collaborator

zemse commented Jul 25, 2021

Related issue #1795 (comment)

@ricmoo
Copy link
Member

ricmoo commented Jul 29, 2021

  1. in my project we set gasPrice explicitly, but not gas limit. this is causing a block deserialization issue here, as the gas estimator appears to call getBlock somewhere and expects to receive the new format

The new block format is optional; if the old block format is received, things keep on trucking. :)

  1. tx.type inference defaults to 1559 regardless of whether it is supported here. This seems like intentional backwards incompatibility?

No, the default is EIP-1559 only on networks which support EIP-1559. For non-EIP-1559 networks this is detected and legacy transactions are used. See the provider.getFeeData() call to detect if EIP-1559 is supported on a given network.

  1. tx.type should be inferred here. it should default to 0 unless an eip1559 property is explicitly set (or the version should be 6.0.0)

If the tx.type is not specified, it uses the network default. On EIP-1559-enabled networks this will ensure a transaction costs no more than it would in a pre-EIP-1559 world (will probably cost less). On a pre-EIP-1559 network it will continue using the same format.

  1. getFeeData (the eth_feeHistory rpc I assume?) called here is not available on kovan or other chains

Which should be fine. If it isn't present, the values for EIP-1559 properties are left null (which is how you can detect EIP-1559 networks)

Are you finding Kovan does not work without specifying type: 0? Ethers currently works fine on Mainnet, despite Mainnet also not having EIP-1559, so I didn't think Kovan would be an issue. But other than getters, Kovan is not tested during the CI for sending transactions. Only Ropsten is tested, as it requires a well-funded faucet.

@ricmoo
Copy link
Member

ricmoo commented Jul 29, 2021

(Note: all changes in 5.4 should be backwards compatible; if you find they are not, provide a concise example and I'll look into it ;))

@prestwich
Copy link

prestwich commented Jul 29, 2021

I linked to specific codepaths with explanations of why they break. I am not sure what more concise information you want. 🤔

@ricmoo
Copy link
Member

ricmoo commented Jul 29, 2021

@prestwich An example of a transaction (preferably to a verified contract) on Kovan that doesn't work, and the error it gives.

The code paths you linked to, should not be an issue. Otherwise homestead would also have broke, as it also doesn't have London activated yet. :)

@prestwich
Copy link

it's not whether London is activated, it's whether the rpc method gives a response or a method-not-found error

@prestwich
Copy link

Screen Shot 2021-07-29 at 15 31 34

@ricmoo
Copy link
Member

ricmoo commented Jul 29, 2021

e.g. for your point 2, check the code path. type is set to 2 occurs if and only if type == null and a maxFeePerGas and maxPriorityFeePerGas are both set. If you use EIP-1559 properties, you are forcing an EIP-1559 transaction.

There could well be bugs, but that is why I need an example transaction. :)

@ricmoo
Copy link
Member

ricmoo commented Jul 29, 2021

I don't use eth_feeHistory yet (and when I do, it will be wrapped in the appropriate .catch so it shouldn't be an issue on networks that fail on it).

@prestwich
Copy link

prestwich commented Jul 29, 2021

here's your concise example lmao:

import * as ethers from 'ethers';

const provider = new ethers.providers.JsonRpcProvider(
  'https://kovan.infura.io/v3/590d1a16f5b642a8b89bd2cee1d598de',
);

const wallet = new ethers.Wallet(process.env.KEY!, provider);

wallet.sendTransaction({ to: wallet.address, value: 0 });
james@Sisyphus ~/devel/optics-monorepo/typescript/optics-deploy                                                                                                                                                [15:37:00] 
> $ npx ts-node ./tmp.ts                                                                                                                                                              ⬡ 15.14.0 [±prestwich/eth-helper ✓]

/Users/james/devel/optics-monorepo/typescript/optics-deploy/node_modules/@ethersproject/logger/src.ts/index.ts:213
        const error: any = new Error(message);
                           ^
Error: cannot estimate gas; transaction may fail or may require manual gas limit (error={"reason":"processing response error","code":"SERVER_ERROR","body":"{\"jsonrpc\":\"2.0\",\"id\":49,\"error\":{\"code\":-32602,\"message\":\"Invalid params\"}}","error":{"code":-32602},"requestBody":"{\"method\":\"eth_estimateGas\",\"params\":[{\"gasPrice\":\"0x12a05f200\",\"type\":\"0x0\",\"from\":\"0xa4849f1d96b26066f9c631fcdc8f1457d27fb5ec\",\"to\":\"0xa4849f1d96b26066f9c631fcdc8f1457d27fb5ec\"}],\"id\":49,\"jsonrpc\":\"2.0\"}","requestMethod":"POST","url":"https://kovan.infura.io/v3/590d1a16f5b642a8b89bd2cee1d598de"}, tx={"to":{},"value":0,"from":"0xa4849f1D96B26066f9C631FCdc8F1457D27Fb5EC","gasPrice":{"type":"BigNumber","hex":"0x012a05f200"},"type":0,"nonce":{},"gasLimit":{},"chainId":{}}, code=UNPREDICTABLE_GAS_LIMIT, version=abstract-signer/5.4.0)
    at Logger.makeError (/Users/james/devel/optics-monorepo/typescript/optics-deploy/node_modules/@ethersproject/logger/src.ts/index.ts:213:28)
    at Logger.throwError (/Users/james/devel/optics-monorepo/typescript/optics-deploy/node_modules/@ethersproject/logger/src.ts/index.ts:225:20)
    at /Users/james/devel/optics-monorepo/typescript/optics-deploy/node_modules/@ethersproject/abstract-signer/src.ts/index.ts:300:31
    at processTicksAndRejections (node:internal/process/task_queues:94:5)
    at async Promise.all (index 6)
                                             

@ricmoo
Copy link
Member

ricmoo commented Jul 29, 2021

Thanks! Exactly what I needed. :)

From the error, it looks like the issue is the explicit type: 0 in the estimate payload, so estimateGas will need to detect EIP-1559 and not send it on pre-EIP-1559 networks.

@ricmoo
Copy link
Member

ricmoo commented Jul 29, 2021

@prestwich As a side note, I've just confirmed the issue is only with Alchemy and INFURA. If you use the EtherscanProvider, it will work fine; if you need a quick work around. This is also why the default provider works, the sendTransaction hits all them at once, and returns whichever one returns a non-error.

So for a quick work around, I recommend:

const provider = ethers.getDefaultProvider("koran");

// or

const provider = new ethers.providers.EtherscanProvider("kovan");

I'll get a fix out as soon as possible for the others.

@ricmoo ricmoo added bug Verified to be an issue. on-deck This Enhancement or Bug is currently being worked on. and removed investigate Under investigation and may be a bug. labels Jul 29, 2021
@ricmoo
Copy link
Member

ricmoo commented Jul 30, 2021

This has been fixed in 5.4.3.

For future reference, anyone who happens across this issue, the cause was an bug in the JsonRpcProvider for estimateGas and call on networks which did not implement EIP-2930 (Berlin), which is why it only showed up on Kovan (which at this time has not implemented the Berlin hard fork from earlier this year).

For a network that supports Berlin, the type field is allowed in call and estimateGas calls and the JsonRpcProvider would use a type of 0 to indicate legacy operation. Before Berlin though, type was extraneous and therefore error out.

The EtherscanProvider worked fine though (I guess they ignore random other properties), which is why the default provider also worked; all the JSON-RPC backed providers would throw an error, but the EtherscanProvider in the mix picked up the slack.

Anyhoo, it should be fixed. But please let me know if you continue to experience any issues. :)

@ricmoo ricmoo removed the on-deck This Enhancement or Bug is currently being worked on. label Jul 30, 2021
@transmissions11
Copy link

hey im still seeing this with Alchemy and Infura on Kovan right now

Error: cannot estimate gas; transaction may fail or may require manual gas limit (error={"reason":"processing response error","code":"SERVER_ERROR","body":"{\"jsonrpc\":\"2.0\",\"id\":135,\"error\":{\"code\":-32602,\"message\":\"Invalid params\"}}",

looks like they still dont support a type field on eth_estimateGas

@ricmoo
Copy link
Member

ricmoo commented Aug 19, 2021

@TransmissionsDev

The type field shouldn't be passed along to any network that doesn't support EIP-1559 anymore though.

Have you updated to the latest version of ethers? The error you provided looks incomplete, it should contain more data about the request.

@transmissions11
Copy link

transmissions11 commented Aug 19, 2021

@TransmissionsDev

The type field shouldn't be passed along to any network that doesn't support EIP-1559 anymore though.

Kovan has upgraded to support EIP-1559 (see this tx for proof), still seeing the issue.

Have you updated to the latest version of ethers? The error you provided looks incomplete, it should contain more data about the request.

Yep i'm on latest. And yea truncated the full error message.

@ricmoo
Copy link
Member

ricmoo commented Aug 19, 2021

Can you please include the full error?

@transmissions11
Copy link

transmissions11 commented Aug 19, 2021

Can you please include the full error?

     Error: cannot estimate gas; transaction may fail or may require manual gas limit (error={"reason":"processing response error","code":"SERVER_ERROR","body":"{\"jsonrpc\":\"2.0\",\"id\":135,\"error\":{\"code\":-32602,\"message\":\"Invalid params\"}}","error":{"code":-32602},"requestBody":"{\"method\":\"eth_estimateGas\",\"params\":[{\"gasPrice\":\"0x4190ab00\",\"type\":\"0x0\",\"from\":\"0xa56318dfd89c81c60478fb33f145641a20bef088\",\"to\":\"0x5b90ac1cd9bed8b713c1fd95d9942622ab81a276\",\"data\":\"0x59f7cdfd00000000000000000000000000000000000000000000000000000000000001a40000000000000000000000007a3b04be4304c0412d9e23e04ad6a70d1e8ae98a00000000000000000000000000000000000000000000000000000000000000c000000000000000000000000000000000000000000000000000000000000493e0000000000000000000000000a56318dfd89c81c60478fb33f145641a20bef088000000000000000000000000000000000000000000000000000009184e729fff00000000000000000000000000000000000000000000000000000000000000047261a02400000000000000000000000000000000000000000000000000000000\"}],\"id\":135,\"jsonrpc\":\"2.0\"}","requestMethod":"POST","url":"https://kovan.infura.io/v3/2e56500614ce4496bde29b22e65f1607"}, tx={"data":"0x59f7cdfd00000000000000000000000000000000000000000000000000000000000001a40000000000000000000000007a3b04be4304c0412d9e23e04ad6a70d1e8ae98a00000000000000000000000000000000000000000000000000000000000000c000000000000000000000000000000000000000000000000000000000000493e0000000000000000000000000a56318dfd89c81c60478fb33f145641a20bef088000000000000000000000000000000000000000000000000000009184e729fff00000000000000000000000000000000000000000000000000000000000000047261a02400000000000000000000000000000000000000000000000000000000","to":{},"from":"0xA56318dfd89C81C60478FB33f145641a20bEf088","type":0,"gasPrice":{},"nonce":{},"gasLimit":{},"chainId":{}}, code=UNPREDICTABLE_GAS_LIMIT, version=abstract-signer/5.4.1)
      at Logger.makeError (node_modules/@ethersproject/logger/src.ts/index.ts:213:28)
      at Logger.throwError (node_modules/@ethersproject/logger/src.ts/index.ts:225:20)
      at /Users/benmayer/Desktop/nova/node_modules/@ethersproject/abstract-signer/src.ts/index.ts:301:31
      at runMicrotasks (<anonymous>)
      at processTicksAndRejections (internal/process/task_queues.js:93:5)
      at async Promise.all (index 6)

@transmissions11
Copy link

the etherscan kovan provider works btw, seems like its specific to infura/alchemy's nodes?

@ricmoo
Copy link
Member

ricmoo commented Aug 19, 2021

I wonder if they haven’t updated yet? Because type is necessary for estimate gas if they have eip-1559 support. It will affect the estimate.

@transmissions11
Copy link

transmissions11 commented Aug 19, 2021

yeah they don't seem to think its a field that estimate gas supports?
Screen Shot 2021-08-19 at 1 03 25 PM

@transmissions11
Copy link

aight an alchemy engineer let me know he thinks its a parity bug 👍

@brg8
Copy link

brg8 commented Aug 20, 2021

Hey there, I'm "the alchemy engineer" :) Just updated our eth_estimateGas endpoint so the legacy type 0x0 should now work. Sorry for all of this inconvenience and thanks for everyone's patience. Also thanks to @ricmoo for diagnosing.

@ricmoo
Copy link
Member

ricmoo commented Aug 20, 2021

@brg8 Thanks for the quick response!

@TransmissionsDev is there still a problem with INFURA? They use Geth, I think, but if there is an issue I can reach out to them.

@transmissions11
Copy link

transmissions11 commented Aug 20, 2021

@brg8 Thanks for the quick response!

@TransmissionsDev is there still a problem with INFURA? They use Geth, I think, but if there is an issue I can reach out to them.

iirc Kovan is OpenEthereum only? but yea still seeing it with Infura :(

     Error: cannot estimate gas; transaction may fail or may require manual gas limit (error={"reason":"processing response error","code":"SERVER_ERROR","body":"{\"jsonrpc\":\"2.0\",\"id\":145,\"error\":{\"code\":-32602,\"message\":\"Invalid params\"}}","error":{"code":-32602},"requestBody":"{\"method\":\"eth_estimateGas\",\"params\":[{\"gasPrice\":\"0x4190ab00\",\"type\":\"0x0\",\"from\":\"0xa56318dfd89c81c60478fb33f145641a20bef088\",\"to\":\"0x9dacc78ca4a5b1c8d8bd0478bb88cc9b4758f57c\",\"data\":\"0x59f7cdfd00000000000000000000000000000000000000000000000000000000000001a4000000000000000000000000fdcd6b9077007e978bdce52b845d39e0c57a487400000000000000000000000000000000000000000000000000000000000000c000000000000000000000000000000000000000000000000000000000000493e0000000000000000000000000a56318dfd89c81c60478fb33f145641a20bef088000000000000000000000000000000000000000000000000000009184e729fff00000000000000000000000000000000000000000000000000000000000000047261a02400000000000000000000000000000000000000000000000000000000\"}],\"id\":145,\"jsonrpc\":\"2.0\"}","requestMethod":"POST","url":"https://kovan.infura.io/v3/2e56500614ce4496bde29b22e65f1607"}, tx={"data":"0x59f7cdfd00000000000000000000000000000000000000000000000000000000000001a4000000000000000000000000fdcd6b9077007e978bdce52b845d39e0c57a487400000000000000000000000000000000000000000000000000000000000000c000000000000000000000000000000000000000000000000000000000000493e0000000000000000000000000a56318dfd89c81c60478fb33f145641a20bef088000000000000000000000000000000000000000000000000000009184e729fff00000000000000000000000000000000000000000000000000000000000000047261a02400000000000000000000000000000000000000000000000000000000","to":{},"from":"0xA56318dfd89C81C60478FB33f145641a20bEf088","type":0,"gasPrice":{},"nonce":{},"gasLimit":{},"chainId":{}}, code=UNPREDICTABLE_GAS_LIMIT, version=abstract-signer/5.4.1)
      at Logger.makeError (node_modules/@ethersproject/logger/src.ts/index.ts:213:28)
      at Logger.throwError (node_modules/@ethersproject/logger/src.ts/index.ts:225:20)
      at /Users/benmayer/Desktop/nova/node_modules/@ethersproject/abstract-signer/src.ts/index.ts:301:31
      at processTicksAndRejections (internal/process/task_queues.js:93:5)
      at async Promise.all (index 6)

@ricmoo
Copy link
Member

ricmoo commented Aug 20, 2021

Oh, interesting. I didn’t realize the consensus engine wasn’t available in Geth, but that kinda makes sense.

Ok, I’ll reach out. Thanks! :)

@ricmoo
Copy link
Member

ricmoo commented Aug 24, 2021

@TransmissionsDev Heya! Looks like Infura has fixed the issue from my tests. Can you confirm with yours?

@ricmoo
Copy link
Member

ricmoo commented Aug 26, 2021

I've also received word from INFURA that it has been fixed, so I'll close this now. If anyone continues having issues, please feel free to re-open.

Thanks! :)

@Kankan-0
Copy link

@ricmoo I have this issue with optimism networks (#2518)
I think it might be somehow related. Can you please take a look when you have some time ?
thanks.

@ratankaliani
Copy link

Currently having this issue on Goerli as well!

@xpluscal
Copy link

@ratankaliani did you find the issue?

@ratankaliani
Copy link

Are you having a server error or invalid argument error?

My issue was an invalid argument to my contract which I resolved by changing the input type. Server error is likely an internet issue of some form.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Verified to be an issue. fixed/complete This Bug is fixed or Enhancement is complete and published.
Projects
None yet
Development

No branches or pull requests