-
Notifications
You must be signed in to change notification settings - Fork 810
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
[pallet-revive] do not trap the caller on instantiations with duplicate contracts #7414
Conversation
…tion Signed-off-by: Cyrill Leutwiler <bigcyrill@hotmail.com>
/cmd prdoc --audience runtime_dev --bump major |
Nice catch. Thank you. I am wondering: The catch blocks of Solidty do also apply to reverts where some data is returned. Do we need to encode some error data here, too? |
Good point. There should be no need for us to encode anything, because the |
You are right we are good here. AFAIK the EVM never encodes anything into the return buffer. That is completely controlled by the callee contract. So for every error in a subcall that is not a revert the Especially |
…te contracts (#7414) This PR changes the behavior of `instantiate` when the resulting contract address already exists (because the caller tried to instantiate the same contract with the same salt multiple times): Instead of trapping the caller, return an error code. Solidity allows `catch`ing this, which doesn't work if we are trapping the caller. For example, the change makes the following snippet work: ```Solidity try new Foo{salt: hex"00"}() returns (Foo) { // Instantiation was successful (contract address was free and constructor did not revert) } catch { // This branch is expected to be taken if the instantiation failed because of a duplicate salt } ``` `revive` PR: paritytech/revive#188 --------- Signed-off-by: Cyrill Leutwiler <bigcyrill@hotmail.com> Co-authored-by: cmd[bot] <41898282+github-actions[bot]@users.noreply.github.com>
This PR changes the behavior of
instantiate
when the resulting contract address already exists (because the caller tried to instantiate the same contract with the same salt multiple times): Instead of trapping the caller, return an error code.Solidity allows
catch
ing this, which doesn't work if we are trapping the caller. For example, the change makes the following snippet work:revive
PR: paritytech/revive#188