-
Notifications
You must be signed in to change notification settings - Fork 357
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
Remove non_exhaustive from IBC message types. #1449
Conversation
That's a noble approach. Better safe than sorry. However, it would require a major version bump of cosmwasm-std just because a new enum case is added. This is what we want to avoid with all the |
I trust that you have more experience with this stuff than I do. :) I do wonder what the odds of a new message being added to the channel establishment or teardown process is? my guess is, that considered, the expected value of this may be positive. also, adding a new case would break all existing IBC contracts that are deployed. perhaps that is worth a major version bump? if we do decide to not merge this it's not a big deal. just need to be very careful bumping CosmWasm versions in IBC contracts. :) |
@ethanfrey what do you think about removing non_exhaustive from those two places? Do we expect new cases here any time soon? |
I agree completely with removing the non_exhaustive flags here. I think there was a bit over eager tagging. I would also remove it here That said, I think CosmosMsg::Ibc(IbcMsg) type will.need non exhaustive and is very likely to receive additional types in 1.x |
Good, thanks. Yeah, the issue with @0xekez I tried the change in an IBC contract it seems like this is non breaking as it would just create a compiler warning for the fallback matche arm:
Out of curiosity, I wonder why you need the match at all. With |
Here's a specific example of where #[cfg_attr(not(feature = "library"), entry_point)]
pub fn ibc_channel_close(
_deps: DepsMut,
_env: Env,
msg: IbcChannelCloseMsg,
) -> Result<IbcBasicResponse, ContractError> {
match msg {
// Error any TX that would cause the channel to close that is
// coming from the local chain.
IbcChannelCloseMsg::CloseInit { channel: _ } => Err(ContractError::CantCloseChannel {}),
// If the close is coming from the other chain, we must allow
// the TX to pass. Otherwise, our chain will believe the
// channel to be open, while our counterparty will believe the
// channel to be closed.
IbcChannelCloseMsg::CloseConfirm { channel: _ } => Ok(IbcBasicResponse::default()),
_ => unreachable!("channel can not be closed"),
}
} We need to match on the close message type as the contract should do something different depending on if this is a "request to close" from the local chain, or a "statement that the channel has been closed" from the counterparty chain. Channel closing is a really dangerous part of these contracts because if you fail the TX which confirms the close on your side, the chains will be out of sync where one side believes the channel closed and the other does not. Here's a test that explores some of the complexities of channels closing. |
IBC message types being non exhaustive means that contract authors have to include a wildcard arm in any match expression deailing with them. IMO, this is actually quite undesirable. I my contract to fail to compile if a message is added!
Rebased and removed |
Merci, thanks for sharing. Will merge next week. |
Shipped as part of 1.1.5 |
IBC message types being non exhaustive means that contract authors have to include a wildcard arm in any match expression deailing with them. IMO, this is actually quite undesirable. I my contract to fail to compile if a message is added!