-
Notifications
You must be signed in to change notification settings - Fork 608
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
Use standard IBC errors #3908
Use standard IBC errors #3908
Conversation
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 nice! Left some minor comments, please take a look
x/ibc-hooks/types/errors.go
Outdated
ErrBadMetadataFormatMsg = "wasm metadata not properly formatted for: '%v'. %s" | ||
ErrBadExecutionMsg = "cannot execute contract: %v" | ||
ErrBadResponse = "cannot create response: %v" | ||
|
||
ErrMsgValidation = sdkerrors.Register("wasm-hooks", 1, "error in wasmhook message validation") |
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.
Just curious why use "wasm-hooks" instead of ModuleName? Also is it possible in this case to avoid using sdkerrors? AFAIK our goal in general is to refrain from using sdk errors
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.
Just curious why use "wasm-hooks" instead of ModuleName?
This error is specific to the validation of the wasm hook. The module could (and probably will in the future) have different hooks. That said, don't mind changing it.
is it possible in this case to avoid using sdkerrors? AFAIK our goal in general is to refrain from using sdk errors
What's the alternative? Ibc internally expects an error with codespace and code id. (https://github.com/cosmos/ibc-go/blob/b40dbc646c7191aaee12d3a70243f9b6f3f80919/modules/core/04-channel/types/acknowledgement.go#L32-L42)
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.
This error is specific to the validation of the wasm hook. The module could (and probably will in the future) have different hooks. That said, don't mind changing it.
Ah I see what you were trying to do. LGTM!
What's the alternative? Ibc internally expects an error with codespace and code id. (https://github.com/cosmos/ibc-go/blob/b40dbc646c7191aaee12d3a70243f9b6f3f80919/modules/core/04-channel/types/acknowledgement.go#L32-L42)
Don't know much about ibc-go but is this the method that receives the error? https://github.com/cosmos/ibc-go/blob/b40dbc646c7191aaee12d3a70243f9b6f3f80919/modules/core/04-channel/types/acknowledgement.go#L32-L35 looks like it takes in go lang error. Or I assume there might be different components in ibc-go that accepts codespace and code-id. If so, please feel free to resolve this comment!
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.
yeah, we can pass a golang errors (the sdk errors are golang errors under the hood). I guess I could define the error type using sdkerrors.New
or manually as Error{codespace: codespace, code: code, desc: desc}
, but not sure what the advantage of doing that would be.
Maybe we should have a standard way to do this across osmosis?
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.
@ValarDragon can you chime in here? I think we should leave these using sdkerrors. AFAICT, passing a normal error to IBC's channeltypes.NewErrorAcknowledgement
will return the default "internalABCICode" (1). Having the code numbers is useful to determine what happened.
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.
We're generally trying to rethink codespacing in cosmos: cosmos/cosmos-sdk#14070
Very few people actually use codespacing in their integrator logic.
I'm not very opinionated on this, since its unlikely these errors are things we'd want to change in a patch release.
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.
I believe we have to start registration from 2 onwards though
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.
Ah given that this is IBC-standard here, agreed with SDK registering these
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.
ok, so, in conclusion: keep sdk errors for this so it matches other IBC errors and move the first code to 2 (which was just an oversight on my part), right?
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.
yup!
}, | ||
// NewEmitErrorAcknowledgement creates a new error acknowledgement after having emitted an event with the | ||
// details of the error. | ||
func NewEmitErrorAcknowledgement(ctx sdk.Context, err error, errorContexts ...string) channeltypes.Acknowledgement { |
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.
Why don't we just move this to ibc-hooks, then we can delete the entire ibc-hooks <> osmoutils dependency
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.
sounds good!
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.
ahh, no. Just realized it's in osmoutils because rate-limiting is also using it (we could have rate limiting import it from wasm hooks, but it seems dirtier)
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.
Didn't we want rate limiting to import ibc-hooks anyway? (This isn't release blocking at all either way though)
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.
yeah, that makes sense. We can change it later when rate limits is based off ibc hooks.
), | ||
}) | ||
|
||
return channeltypes.NewErrorAcknowledgement(err) |
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.
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.
LGTM, we just need to increment codespace by one
* reverted errors to the ibc standard * revision change * updated dependencies * fix rate limit errors * fixed rate limit errors * updated versions * updated commit to after the merge * convert new error * new go mod * increment error codes * updated go mod to latest ibc-hooks Co-authored-by: Dev Ojha <[email protected]>
* Enforce SDK 45 in the dependencies (#3863) * using sdk 45 * added osmoutils to go.sum * move all versions to 0.45 * changed for all * fixed import to latest * updated go.mod * Lifecycle completed without contracts (#3927) * selecting lyfecycle change * updated version and tidy * updated bersions again to one with the proper go.sum * proper counter contract for tests * updated test bytecode * wasm hooks from main * lifecycle message update * go mod tidy * Use standard IBC errors (#3908) * reverted errors to the ibc standard * revision change * updated dependencies * fix rate limit errors * fixed rate limit errors * updated versions * updated commit to after the merge * convert new error * new go mod * increment error codes * updated go mod to latest ibc-hooks Co-authored-by: Dev Ojha <[email protected]> * new commit * update ibc-hook version * Update root version * updated osmomath Co-authored-by: Dev Ojha <[email protected]> Co-authored-by: Dev Ojha <[email protected]>
Refs: #3838 (comment)
What is the purpose of the change
Wasm hooks now uses the standard ibc v4 errors but emits the errors for the user to review.
Brief Changelog
(for example:)
Testing and Verifying
Updated tests to check the errors properly (TODO)
Documentation and Release Note
Unreleased
section inCHANGELOG.md
? (yes / no)x/<module>/spec/
) / Osmosis docs repo / not documented)