Skip to content
This repository has been archived by the owner on Nov 6, 2020. It is now read-only.

eth_call some contract stuck and high CPU #8904

Closed
cedricfung opened this issue Jun 15, 2018 · 12 comments · Fixed by #8943
Closed

eth_call some contract stuck and high CPU #8904

cedricfung opened this issue Jun 15, 2018 · 12 comments · Fixed by #8943
Labels
F2-bug 🐞 The client fails to follow expected behavior. M6-rpcapi 📣 RPC API. P2-asap 🌊 No need to stop dead in your tracks, however issue should be addressed as soon as possible.
Milestone

Comments

@cedricfung
Copy link

Before filing a new issue, please provide the following information.

I'm running:

  • Which Parity version?: Parity/v1.10.6-stable-bc0d134-20180605/x86_64-linux-gnu/rustc1.26.1
  • Which operating system?: Linux
  • How installed?: curl
  • Are you fully synchronized?: yes
  • Which network are you connected to?: ethereum
  • Did you try to restart the node?: yes

Your issue description goes here below. Try to include actual vs. expected behavior and steps to reproduce the issue.

curl --data '{"method":"eth_call","params":[{"data":"0x95d89b41","to":"0x532975d56cf18f597480e2521246b273ad9ae348"}],"id":1,"jsonrpc":"2.0"}' -H "Content-Type: application/json" -X POST http://localhost:8545

This will cause the parity CPU high and never respond. If I run this a few times, the parity won't accept any new RPC calls, I have to restart it.

@Tbaut Tbaut added Z1-question 🙋‍♀️ Issue is a question. Closer should answer. M6-rpcapi 📣 RPC API. labels Jun 15, 2018
@Tbaut
Copy link
Contributor

Tbaut commented Jun 15, 2018

I don't think that your call is valid, you should pad the function signature to the left to 32 bytes.
Could you describe which function you want to call and what parameter?

Just tested a random call:

curl --data '{"method":"eth_call","params":[{"data":"0xa0e67e2b0000000000000000000000000000000000000000000000000000000000000000","to":"0x71da31e0a3100f964f5bd3b498cafbf26e82e46c"}],"id":1,"jsonrpc":"2.0"}' -H "Content-Type: application/json" -X POST http://localhost:8545

Result:

{"jsonrpc":"2.0","result":"0x00000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000003000000000000000000000000b34f87a1fda8ff1cf412acb8e8f40583968b7172000000000000000000000000dfd2418ade41eb2b9b79add7d62e6780e963b3e7000000000000000000000000fdf6ddd2585e8a9bc34cd3c02729c52126878139","id":1}

@Tbaut Tbaut added this to the 1.12 milestone Jun 15, 2018
@cedricfung
Copy link
Author

I try to test whether the contract will respond to some method, all other contracts work as expected only the one I posted stuck.

I tried to pad the function signature to 32 bytes, the bug still exists.

curl --data '{"method":"eth_call","params":[{"data":"0x95d89b410000000000000000000000000000000000000000000000000000000000000000","to":"0x532975d56cf18f597480e2521246b273ad9ae348"}],"id":1,"jsonrpc":"2.0"}' -H "Content-Type: application/json" -X POST http://localhost:8545

@Tbaut
Copy link
Contributor

Tbaut commented Jun 15, 2018

Could you describe which function you want to call?

@cedricfung
Copy link
Author

The signature 95d89b41 is ERC20 symbol function, I want to know whether the contract is a valid ERC20 contract with all information. The contract which causes the bug is 0x532975d56cf18f597480e2521246b273ad9ae348

@Tbaut
Copy link
Contributor

Tbaut commented Jun 18, 2018

I have difficulties to follow you. There is no ERC20 symbol function in the ERC20 standard and there is no symbol function in the contract's code. It looks like you're trying to call a function that simply does not exist.

@cedricfung
Copy link
Author

It's not in the standard, but it's how most ERC20 tokens are using it. Almost all ERC20 tokens have a symbol function.

Anyway, no matter what the function is, parity should not stuck and consume high CPU. Is parity expected to stuck whenever people call a function not exist in a contract? Isn't it a bug?

@Tbaut Tbaut added F2-bug 🐞 The client fails to follow expected behavior. and removed Z1-question 🙋‍♀️ Issue is a question. Closer should answer. labels Jun 18, 2018
@Tbaut
Copy link
Contributor

Tbaut commented Jun 18, 2018

I agree. It's reproducible on 1.11.3 also with curl --data '{"method":"eth_call","params":[{"data":"0x95d89b410000000000000000000000000000000000000000000000000000000000000000","to":"0x532975d56cf18f597480e2521246b273ad9ae348"}],"id":1,"jsonrpc":"2.0"}' -H "Content-Type: application/json" -X POST http://localhost:8545

@Tbaut Tbaut added P2-asap 🌊 No need to stop dead in your tracks, however issue should be addressed as soon as possible. Q3-medium A fair chunk of work, not necessarily very hard but not trivial either labels Jun 18, 2018
@Tbaut Tbaut removed the Q3-medium A fair chunk of work, not necessarily very hard but not trivial either label Jun 19, 2018
@andresilva
Copy link
Contributor

Can you check whether this is parity specific or does it also happen in geth? It would be easier if you could provide a smaller reproduction case (minimal set of contract functionality that triggers the issue).

@Tbaut
Copy link
Contributor

Tbaut commented Jun 21, 2018

@debris had ideas regarding this as it might be related to the way we call functions in the EVM with unlimited gas.

@cedricfung
Copy link
Author

cedricfung commented Jun 21, 2018 via email

@andresilva
Copy link
Contributor

It does work on Etherscan but doesn't return the appropriate result. Just returns "0x" because the contract runs out of gas. Currently in parity we have effectively unlimited gas for local calls, so if your contract is stuck on some loop it will keep looping "forever" (or just a really long time). I've capped the gas limit to make sure this doesn't happen (#8943). In the meantime you can enforce a gas limit yourself when doing the request:

❯ curl --data '{"method":"eth_call","params":[{"data":"0x95d89b41","to":"0x532975d56cf18f597480e2521246b273ad9ae348","gas":"0x100000000"}],"id":1,"jsonrpc":"2.0"}' -H "Content-Type: application/json" -X POST http://localhost:8545
{"jsonrpc":"2.0","error":{"code":-32015,"message":"VM execution error.","data":"Reverted 0x"},"id":1}

@cedricfung
Copy link
Author

Yes, the gas limit fixes the problem

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
F2-bug 🐞 The client fails to follow expected behavior. M6-rpcapi 📣 RPC API. P2-asap 🌊 No need to stop dead in your tracks, however issue should be addressed as soon as possible.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants