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

Return ContractReverted from dispatchables when top level contract reverted #9338

Closed
athei opened this issue Jul 13, 2021 · 0 comments · Fixed by #10481
Closed

Return ContractReverted from dispatchables when top level contract reverted #9338

athei opened this issue Jul 13, 2021 · 0 comments · Fixed by #10481
Assignees
Labels
J0-enhancement An additional feature request. Z1-easy Can be fixed primarily by duplicating and adapting code by an intermediate coder

Comments

@athei
Copy link
Member

athei commented Jul 13, 2021

Contracts have the possibility to set a flag that reverts all the changes they made. The calling contract can evaluate these flags and act on it. However, if the top level contract sets the revert flag when returning the extrinsic is counted as Ok. We should introduce a new pallet level error Err(ContractReverted) that is returned instead.

Please note that seal_return allows to return a result buffer that can be used to encode additional error information. The buffer is only accessible when calling via RPC of course. How this buffer is to be decoded (by a UI) for a specific contract should be defined by the userspace ABI (json). When called via RPC we return Ok so that buffer is accessible. UIs should inspect the flags field in order to determine whether the call was a success.

Please note that this should only happen if the call/instantiate was submitted as transaction where the flags field cannot be read. An RPC call should still return OK and it is up to the UI to classify it as error by reading flags. Reason is that on dispatch error no output buffer could be returned.

@athei athei added J0-enhancement An additional feature request. Z1-easy Can be fixed primarily by duplicating and adapting code by an intermediate coder labels Jul 13, 2021
@athei athei self-assigned this Dec 14, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
J0-enhancement An additional feature request. Z1-easy Can be fixed primarily by duplicating and adapting code by an intermediate coder
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

1 participant