-
Notifications
You must be signed in to change notification settings - Fork 765
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
VM: Create collisions using runCode() and runCall() #613
Comments
Geez, that's some corner case :)
That seems like a fair solution to me. |
@alcuadrado I'll take a look |
Feel free to ask any questions. I think the hardest part of this would be deciding where and how to test these changes. |
We should absolutely add a nonce to I think a related issue here is #799, we might want to merge these two issues into a single PR? |
Heya, I thought implementing nonce in The reason is that However, iff I conclude that it makes no sense to include nonces in |
Adding this nonce option temporarily changes the nonces of the calling account, runs the call, and then changes it back to the original value. This could lead to undesired (?) side effects where the balance of the account is changed (i.e. besides deducting gas costs the code could also send some ETH over to the sender). I therefore do not know if we want to implement this feature. @alcuadrado isn't it better to use Thoughts? @holgerd77 @s1na @ryanio @evertonfraga |
Yes, that's actually what I'm doing. I checked ganache's code, and they do the same. |
What to do with this issue? Close? Or are there still some design adoption considerations to be drawn from here (didn't re-read to closely TBH)? |
just catching up, so @alcuadrado you solved your issue here by moving to is anyone actually using (oops accidentally closed the issue when posting the comment, re-opened) |
Yeah, it was solved by moving to runTx. I don't think |
I think We might want to consider to deprecate |
I think that'd make sense. I agree with the |
@jochem-brouwer Just stumbled into this old issue which seems related to the discussions in #2861 |
Hi @jochem-brouwer, can you please take (short-term) responsibility of this issue? Closing is definitely an option. If you have some alternative suggestion for an implementation please open a new issue with an evolved and concrete proposal and close this issue. Thanks! 🙏 |
Thanks for the ping @holgerd77, took a look, this is the intended behavior. The EVM is supposed to runCall / runCode on top of some state (which is identified by the state root). Therefore, if you try to first run a call (which creates a contract), and then run the call again (but now on the "new state"), this indeed creates an address clash, but ONLY if the original sender was supposed to be an EOA. In our There are two simple ways to get around this:
Will close. |
@jochem-brouwer Thanks for having a look and the detailed "closing-analysis"! 🙏 👍 |
I'm not completely sure if this should be considered a bug because I don't understand what the intended use case of
runCode
andrunCall
methods is, but using them can lead to unexpectedCREATE_COLLISION
errors.This can be reproduced like this:
Account
with some ETH.runCall
to simulate a call to the null address.runCall
will try to deploy the contract, and fail. This is because contract addresses are computed using the caller and their nonce. In this case, the caller is the account that we created, and the nonce is always 0 forrunCall
andrunCode
. But we already deployed a contract from the 0-nonce TX of that account, so an address clash happens.This is a corner case that I found right before shipping Buidler EVM 😅 I was using
runCall
in oureth_call
RPC implementation and started seeingCREATE_COLLISION
errors when testing with real codebases. It may seem weird to run a deployment witheth_call
, but some projects do it to get revert reasons from failed txs.My solution was to use use a
FakeTransaction
andrunTx
, and revert any state change. I guess that's whyFakeTransaction
was created in the first place. I really wanted to remove it when migrating-tx
to TS, but I'm happy I didn't :)Should we add
nonce
toRunCodeOpts
andRunCallOpts
?The text was updated successfully, but these errors were encountered: