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

eth_call can't be implemented without copy-pasting code form the VM #1014

Closed
alcuadrado opened this issue Dec 13, 2020 · 2 comments · Fixed by #1039
Closed

eth_call can't be implemented without copy-pasting code form the VM #1014

alcuadrado opened this issue Dec 13, 2020 · 2 comments · Fixed by #1039

Comments

@alcuadrado
Copy link
Member

I just found a bug in Hardhat Network's implementation of eth_call, which I'm currently fixing it, and realized that I'll have to copy paste a bunch fo code from the VM to do it.

Our implementation of eth_call uses vm.runTx, instead of vm.runCall, as the latter can fail. But runTx wasn't really designed for this, and I'm hitting a limitation.

When you execute eth_call, you can run your call in the context of a block, and it should be as close as possible to running a tx as the last one in the block. This means that you need to keep things like block.timestamp and block.gasLimit in sync.

eth_call also accepts a gas limit param, which doesn't need to be capped by block.gasLimit. Actually, it's normally higher. For example, Geth accepts up to 25000000 regardless of the block gas limit.

My problem is that runTx checks that the tx's gas limit is <= than the block's one here. So, I need to do something like this myself, but _runTx is not exported, so I'd need to copy everything.

As a "workaround" I can modify the block, setting its gas limit to the eth_call's one right before execution, but that behavior is slightly incorrect.

In the meantime, I'll implement that workaround, but it'd be great to have a way to implement this properly. We are not on v5 yet, so even if we somehow fix this, I'll need the workaround for about a month.

@jochem-brouwer
Copy link
Member

Would it be an idea to add an option to runTx which skips these checks?

@alcuadrado
Copy link
Member Author

alcuadrado commented Dec 15, 2020

That should work. I'm still unsure if using runTx is the best option for eth_call, but it is, your proposal should be enough.

I know it's the best option now, but something tells me that runCall should be enough with a slightly different design.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants