-
Notifications
You must be signed in to change notification settings - Fork 14
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
250 improve error handling in chain extension #349
Conversation
… index in chain extension
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good overall 👍
A few remarks that came to my mind.
- It's probably a good idea to return a value that indicates 'success' for chain extension functions that are changing state. I can see that Astar is returning a 'Success'-error for each mutating function.
- We might also want to consider implementing a conversion from number -> Error type, like eg. here. This way, the error enum could also be re-used in ink! smart contracts that want to interact with our chain extension. (This is not super useful until we extracted the chain extension into an extra crate here, but still nice to have).
I understand the conversion back from number to chain extension error, and I think also returning a success is more readable than 0. Then I would propose to rename the enum to something that is not |
Sure. I would be fine with |
I've added the conversion from u32 to |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No complaints from me.
Except for that 1 CI error
I think the CI basically passed because only saving the cache failed, right? Maybe we can just merge it like this |
Does that step in the CI just cleans after the cargo build? In that case yes we should already merge it. Otherwise we can re-check again. |
I think it's fine to ignore. I'll merge it now. |
Closes #250 .
This PR proposes to use the existing
ChainExtensionError
as the enum discussed in the issue, which is now renamedChainExtensionOutcome
which also holds theSuccess
variant.For this, each value is mapped to a corresponding integer, and later we use the corresponding
ChainExtensionOutcome
asu32
when returning.A conversion from
u32
toChainExtensionOutcome
or it's inner variants is also defined