[pallet-revive] do not trap the caller on instantiations with duplicate 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: https://github.com/paritytech/revive/pull/188 --------- Signed-off-by:Cyrill Leutwiler <bigcyrill@hotmail.com> Co-authored-by:
cmd[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Showing
- prdoc/pr_7414.prdoc 20 additions, 0 deletionsprdoc/pr_7414.prdoc
- substrate/frame/revive/src/tests.rs 12 additions, 0 deletionssubstrate/frame/revive/src/tests.rs
- substrate/frame/revive/src/wasm/runtime.rs 2 additions, 0 deletionssubstrate/frame/revive/src/wasm/runtime.rs
- substrate/frame/revive/uapi/src/lib.rs 3 additions, 0 deletionssubstrate/frame/revive/uapi/src/lib.rs
Please register or sign in to comment