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

utility.dispatch_as error handling #219

Open
sander2 opened this issue Feb 3, 2023 · 4 comments
Open

utility.dispatch_as error handling #219

sander2 opened this issue Feb 3, 2023 · 4 comments
Labels
C1-mentor A task where a mentor is available. Please indicate in the issue who the mentor could be. D0-easy Can be fixed primarily by duplicating and adapting code by an intermediate coder. I5-enhancement An additional feature request. T1-FRAME This PR/Issue is related to core FRAME, the framework.

Comments

@sander2
Copy link

sander2 commented Feb 3, 2023

The utility.dispatch_as function hides errors: https://github.com/paritytech/substrate/blob/8186c519a861ea519ed3dc4391f6e13f64300ce6/frame/utility/src/lib.rs#L392-L405

This is problematic when you have dispatch_as calls within batch_all calls - the batch will succeed despite errors. I assume that you won't want to change the behavior of existing extrinsics, so it would be really nice if a new function could be added that propagates the error. I'm struggling to come up with a suitable name to distinguish it from the extisting dispatch_as though..

@ggwpez
Copy link
Member

ggwpez commented Feb 3, 2023

Yea it looks a bit weird. That call is more of an force_dispatch_as, since it ignores the error.
I think it makes sense to change, since it can still be wrapped in a force_batch to ignore the error - if desired.

@xlc
Copy link
Contributor

xlc commented Feb 4, 2023

Not saying this is desired behaviour but it is intended behaviour consistent with other similar code.

The reason is that the disaptch_as have successfully dispatched a call and therefore the Ok response. If for example the origin check failed, it will then respond Err. It is not good to merge errors which could cause more confusion.

@sander2
Copy link
Author

sander2 commented Feb 6, 2023

Not saying this is desired behaviour but it is intended behaviour consistent with other similar code.

The reason is that the disaptch_as have successfully dispatched a call and therefore the Ok response. If for example the origin check failed, it will then respond Err. It is not good to merge errors which could cause more confusion.

Yea you can certainly argue that it's working as intended. I'd be fine with leaving the existing function untouched. You can consider this a feature request rather than a bug report. Just to illustrate the need of a dispatch_as variant that propagates errors, let me explain how I ran into this issue.

I had a batch of ~50 calls initializing a new testnet. I wrapped the calls in batch_all since I wanted an all-or-nothing approach - some of the calls would only have the desired behavior if all of the previous calls succeeded. However, there was a failure hidden by some of the dispatch_as calls within the batch, and as a result the batch was committed, resulting in an unintended chain state that was very difficult to fix.

@juangirini juangirini transferred this issue from paritytech/substrate Aug 24, 2023
@the-right-joyce the-right-joyce added C1-mentor A task where a mentor is available. Please indicate in the issue who the mentor could be. T1-FRAME This PR/Issue is related to core FRAME, the framework. D0-easy Can be fixed primarily by duplicating and adapting code by an intermediate coder. and removed Z6-mentor labels Aug 25, 2023
@0xmovses
Copy link
Contributor

Any reason why the linked PR was not merged even though it was approved? paritytech/substrate#13387

Do we still want the changes in submitted in the PR?

@ggwpez ggwpez added the I5-enhancement An additional feature request. label Feb 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C1-mentor A task where a mentor is available. Please indicate in the issue who the mentor could be. D0-easy Can be fixed primarily by duplicating and adapting code by an intermediate coder. I5-enhancement An additional feature request. T1-FRAME This PR/Issue is related to core FRAME, the framework.
Projects
Status: Backlog
Development

No branches or pull requests

6 participants