diff --git a/CHANGELOG.md b/CHANGELOG.md index 00f9418771..058d3a6817 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -29,8 +29,10 @@ and this project adheres to - cosmwasm-std: Make inner values of `CanonicalAddr` and `Binary` private and add constructor for `Binary`. ([#1876]) - cosmwasm-vm: Make inner value of `Size` private and add constructor. ([#1876]) +- cosmwasm-std: Remove old IBC version and make v3 the default. ([#1875]) [#1874]: https://github.com/CosmWasm/cosmwasm/pull/1874 +[#1875]: https://github.com/CosmWasm/cosmwasm/pull/1875 [#1876]: https://github.com/CosmWasm/cosmwasm/pull/1876 [#1878]: https://github.com/CosmWasm/cosmwasm/pull/1878 [#1879]: https://github.com/CosmWasm/cosmwasm/pull/1879 diff --git a/MIGRATING.md b/MIGRATING.md index f367462f30..30b18953f9 100644 --- a/MIGRATING.md +++ b/MIGRATING.md @@ -19,6 +19,10 @@ major releases of `cosmwasm`. Note that you can also view the # ... ``` + If you were using cosmwasm-std's `ibc3` feature, you can remove it, as it is + the default now. Depending on your usage, you might have to enable the + `stargate` feature instead, since it was previously implied by `ibc3`. + - `ContractInfoResponse::new` now takes all fields of the response as parameters: diff --git a/contracts/ibc-reflect-send/src/ibc.rs b/contracts/ibc-reflect-send/src/ibc.rs index 511a7b1518..0dadfb53fb 100644 --- a/contracts/ibc-reflect-send/src/ibc.rs +++ b/contracts/ibc-reflect-send/src/ibc.rs @@ -1,7 +1,8 @@ use cosmwasm_std::{ - entry_point, from_json, to_json_binary, DepsMut, Env, IbcBasicResponse, IbcChannelCloseMsg, - IbcChannelConnectMsg, IbcChannelOpenMsg, IbcMsg, IbcOrder, IbcPacketAckMsg, - IbcPacketReceiveMsg, IbcPacketTimeoutMsg, IbcReceiveResponse, Never, StdError, StdResult, + entry_point, from_json, to_json_binary, DepsMut, Env, Ibc3ChannelOpenResponse, + IbcBasicResponse, IbcChannelCloseMsg, IbcChannelConnectMsg, IbcChannelOpenMsg, + IbcChannelOpenResponse, IbcMsg, IbcOrder, IbcPacketAckMsg, IbcPacketReceiveMsg, + IbcPacketTimeoutMsg, IbcReceiveResponse, Never, StdError, StdResult, }; use crate::ibc_msg::{ @@ -17,7 +18,11 @@ pub const PACKET_LIFETIME: u64 = 60 * 60; #[entry_point] /// enforces ordering and versioing constraints -pub fn ibc_channel_open(_deps: DepsMut, _env: Env, msg: IbcChannelOpenMsg) -> StdResult<()> { +pub fn ibc_channel_open( + _deps: DepsMut, + _env: Env, + msg: IbcChannelOpenMsg, +) -> StdResult { let channel = msg.channel(); if channel.order != IbcOrder::Ordered { @@ -37,7 +42,9 @@ pub fn ibc_channel_open(_deps: DepsMut, _env: Env, msg: IbcChannelOpenMsg) -> St } } - Ok(()) + Ok(Some(Ibc3ChannelOpenResponse { + version: IBC_APP_VERSION.to_string(), + })) } #[entry_point] diff --git a/contracts/ibc-reflect/Cargo.toml b/contracts/ibc-reflect/Cargo.toml index ead27d3725..cd16b206e3 100644 --- a/contracts/ibc-reflect/Cargo.toml +++ b/contracts/ibc-reflect/Cargo.toml @@ -33,7 +33,7 @@ backtraces = ["cosmwasm-std/backtraces", "cosmwasm-vm/backtraces"] [dependencies] cosmwasm-schema = { path = "../../packages/schema" } -cosmwasm-std = { path = "../../packages/std", features = ["iterator", "ibc3"] } +cosmwasm-std = { path = "../../packages/std", features = ["iterator", "stargate"] } schemars = "0.8.3" serde = { version = "1.0.103", default-features = false, features = ["derive"] } diff --git a/docs/USING_COSMWASM_STD.md b/docs/USING_COSMWASM_STD.md index 19a04bdb66..49cf3511d4 100644 --- a/docs/USING_COSMWASM_STD.md +++ b/docs/USING_COSMWASM_STD.md @@ -39,7 +39,6 @@ The libarary comes with the following features: | iterator | x | Storage iterators | | abort | x | A panic handler that aborts the contract execution with a helpful message | | stargate | | Cosmos SDK 0.40+ features and IBC | -| ibc3 | | New fields added in IBC v3 | | staking | | Access to the staking module | | backtraces | | Add backtraces to errors (for unit testing) | | cosmwasm_1_1 | | Features that require CosmWasm 1.1+ on the chain | diff --git a/packages/go-gen/Cargo.toml b/packages/go-gen/Cargo.toml index 12035ed5a0..8e5ef67d65 100644 --- a/packages/go-gen/Cargo.toml +++ b/packages/go-gen/Cargo.toml @@ -9,7 +9,7 @@ publish = false [dependencies] schemars = "0.8.3" -cosmwasm-std = { path = "../std", version = "1.5.0", features = ["cosmwasm_1_4", "staking", "stargate", "ibc3"] } +cosmwasm-std = { path = "../std", version = "1.5.0", features = ["cosmwasm_1_4", "staking", "stargate"] } cosmwasm-schema = { path = "../schema", version = "1.5.0" } anyhow = "1" Inflector = "0.11.4" diff --git a/packages/std/Cargo.toml b/packages/std/Cargo.toml index aa3f92219a..2ab60fcb5f 100644 --- a/packages/std/Cargo.toml +++ b/packages/std/Cargo.toml @@ -9,7 +9,7 @@ license = "Apache-2.0" readme = "README.md" [package.metadata.docs.rs] -features = ["abort", "stargate", "staking", "ibc3", "cosmwasm_1_4"] +features = ["abort", "stargate", "staking", "cosmwasm_1_4"] [features] default = ["iterator", "abort"] @@ -30,9 +30,6 @@ backtraces = [] # stargate enables stargate-dependent messages and queries, like raw protobuf messages # as well as ibc-related functionality stargate = [] -# ibc3 extends ibc messages with ibc-v3 only features. This should only be enabled on contracts -# that require these types. Without this, they get the smaller ibc-v1 API. -ibc3 = ["stargate"] # This feature makes `BankQuery::Supply` available for the contract to call, but requires # the host blockchain to run CosmWasm `1.1.0` or higher. cosmwasm_1_1 = [] diff --git a/packages/std/src/exports.rs b/packages/std/src/exports.rs index c745bc82e7..9cbd92fb8e 100644 --- a/packages/std/src/exports.rs +++ b/packages/std/src/exports.rs @@ -15,10 +15,10 @@ use serde::de::DeserializeOwned; use crate::deps::OwnedDeps; #[cfg(feature = "stargate")] use crate::ibc::{ - IbcBasicResponse, IbcChannelCloseMsg, IbcChannelConnectMsg, IbcChannelOpenMsg, - IbcChannelOpenResponse, IbcPacketAckMsg, IbcPacketReceiveMsg, IbcPacketTimeoutMsg, - IbcReceiveResponse, + IbcBasicResponse, IbcChannelCloseMsg, IbcChannelConnectMsg, IbcPacketAckMsg, + IbcPacketReceiveMsg, IbcPacketTimeoutMsg, IbcReceiveResponse, }; +use crate::ibc::{IbcChannelOpenMsg, IbcChannelOpenResponse}; use crate::imports::{ExternalApi, ExternalQuerier, ExternalStorage}; use crate::memory::{alloc, consume_region, release_buffer, Region}; #[cfg(feature = "abort")] @@ -529,7 +529,6 @@ where query_fn(deps.as_ref(), env, msg).into() } -#[cfg(feature = "stargate")] fn _do_ibc_channel_open( contract_fn: &dyn Fn(DepsMut, Env, IbcChannelOpenMsg) -> Result, env_ptr: *mut Region, diff --git a/packages/std/src/ibc.rs b/packages/std/src/ibc.rs index 6631312527..ceba3ad015 100644 --- a/packages/std/src/ibc.rs +++ b/packages/std/src/ibc.rs @@ -5,7 +5,6 @@ use core::cmp::{Ord, Ordering, PartialOrd}; use schemars::JsonSchema; use serde::{Deserialize, Serialize}; -#[cfg(feature = "ibc3")] use crate::addresses::Addr; use crate::binary::Binary; use crate::coin::Coin; @@ -299,11 +298,9 @@ impl From for IbcChannel { } } -/// Note that this serializes as "null". -#[cfg(not(feature = "ibc3"))] -pub type IbcChannelOpenResponse = (); -/// This serializes either as "null" or a JSON object. -#[cfg(feature = "ibc3")] +/// This serializes either as `null` or a JSON object. +/// Within the response, a channel version can be specified. +/// If `null` is provided instead, the incoming channel version is accepted. pub type IbcChannelOpenResponse = Option; #[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)] @@ -405,17 +402,10 @@ impl From for IbcChannel { #[non_exhaustive] pub struct IbcPacketReceiveMsg { pub packet: IbcPacket, - #[cfg(feature = "ibc3")] pub relayer: Addr, } impl IbcPacketReceiveMsg { - #[cfg(not(feature = "ibc3"))] - pub fn new(packet: IbcPacket) -> Self { - Self { packet } - } - - #[cfg(feature = "ibc3")] pub fn new(packet: IbcPacket, relayer: Addr) -> Self { Self { packet, relayer } } @@ -427,20 +417,10 @@ impl IbcPacketReceiveMsg { pub struct IbcPacketAckMsg { pub acknowledgement: IbcAcknowledgement, pub original_packet: IbcPacket, - #[cfg(feature = "ibc3")] pub relayer: Addr, } impl IbcPacketAckMsg { - #[cfg(not(feature = "ibc3"))] - pub fn new(acknowledgement: IbcAcknowledgement, original_packet: IbcPacket) -> Self { - Self { - acknowledgement, - original_packet, - } - } - - #[cfg(feature = "ibc3")] pub fn new( acknowledgement: IbcAcknowledgement, original_packet: IbcPacket, @@ -459,17 +439,10 @@ impl IbcPacketAckMsg { #[non_exhaustive] pub struct IbcPacketTimeoutMsg { pub packet: IbcPacket, - #[cfg(feature = "ibc3")] pub relayer: Addr, } impl IbcPacketTimeoutMsg { - #[cfg(not(feature = "ibc3"))] - pub fn new(packet: IbcPacket) -> Self { - Self { packet } - } - - #[cfg(feature = "ibc3")] pub fn new(packet: IbcPacket, relayer: Addr) -> Self { Self { packet, relayer } } diff --git a/packages/std/src/lib.rs b/packages/std/src/lib.rs index ea04f23dc1..df60c6debc 100644 --- a/packages/std/src/lib.rs +++ b/packages/std/src/lib.rs @@ -51,11 +51,12 @@ pub use crate::errors::{ VerificationError, }; pub use crate::hex_binary::HexBinary; +pub use crate::ibc::IbcChannelOpenResponse; pub use crate::ibc::{ Ibc3ChannelOpenResponse, IbcAcknowledgement, IbcBasicResponse, IbcChannel, IbcChannelCloseMsg, - IbcChannelConnectMsg, IbcChannelOpenMsg, IbcChannelOpenResponse, IbcEndpoint, IbcMsg, IbcOrder, - IbcPacket, IbcPacketAckMsg, IbcPacketReceiveMsg, IbcPacketTimeoutMsg, IbcReceiveResponse, - IbcTimeout, IbcTimeoutBlock, + IbcChannelConnectMsg, IbcChannelOpenMsg, IbcEndpoint, IbcMsg, IbcOrder, IbcPacket, + IbcPacketAckMsg, IbcPacketReceiveMsg, IbcPacketTimeoutMsg, IbcReceiveResponse, IbcTimeout, + IbcTimeoutBlock, }; #[cfg(feature = "iterator")] pub use crate::iterator::{Order, Record}; diff --git a/packages/std/src/testing/mock.rs b/packages/std/src/testing/mock.rs index 4218f729f5..2db41403d5 100644 --- a/packages/std/src/testing/mock.rs +++ b/packages/std/src/testing/mock.rs @@ -433,7 +433,6 @@ pub fn mock_ibc_packet_recv( } .into(), }, - #[cfg(feature = "ibc3")] Addr::unchecked("relayer"), )) } @@ -476,25 +475,20 @@ pub fn mock_ibc_packet_ack( Ok(IbcPacketAckMsg::new( ack, packet, - #[cfg(feature = "ibc3")] Addr::unchecked("relayer"), )) } /// Creates a IbcPacketTimeoutMsg for testing ibc_packet_timeout. You set a few key parameters that are /// often parsed. If you want to set more, use this as a default and mutate other fields. -/// The difference from mock_ibc_packet_recv is if `my_channel_id` is src or dest./ +/// The difference from mock_ibc_packet_recv is if `my_channel_id` is src or dest. #[cfg(feature = "stargate")] pub fn mock_ibc_packet_timeout( my_channel_id: &str, data: &impl Serialize, ) -> StdResult { let packet = mock_ibc_packet(my_channel_id, data)?; - Ok(IbcPacketTimeoutMsg::new( - packet, - #[cfg(feature = "ibc3")] - Addr::unchecked("relayer"), - )) + Ok(IbcPacketTimeoutMsg::new(packet, Addr::unchecked("relayer"))) } /// The same type as cosmwasm-std's QuerierResult, but easier to reuse in diff --git a/packages/vm/Cargo.toml b/packages/vm/Cargo.toml index 8eeba737ee..f3211bcf3b 100644 --- a/packages/vm/Cargo.toml +++ b/packages/vm/Cargo.toml @@ -21,7 +21,7 @@ backtraces = [] iterator = ["cosmwasm-std/iterator"] staking = ["cosmwasm-std/staking"] # this enables all stargate-related functionality, including the ibc entry points -stargate = ["cosmwasm-std/stargate", "cosmwasm-std/ibc3"] +stargate = ["cosmwasm-std/stargate"] # Use cranelift backend instead of singlepass. This is required for development on Windows. cranelift = ["wasmer/cranelift"] # It's a bit unclear if interface_version_7 (CosmWasm 0.16) contracts are fully compatible diff --git a/packages/vm/src/calls.rs b/packages/vm/src/calls.rs index 5828b02102..d64216380f 100644 --- a/packages/vm/src/calls.rs +++ b/packages/vm/src/calls.rs @@ -825,9 +825,10 @@ mod tests { use crate::testing::{ mock_env, mock_info, mock_instance, MockApi, MockQuerier, MockStorage, }; + use cosmwasm_std::testing::mock_ibc_packet_timeout; use cosmwasm_std::testing::{ mock_ibc_channel_close_init, mock_ibc_channel_connect_ack, mock_ibc_channel_open_init, - mock_ibc_packet_ack, mock_ibc_packet_recv, mock_ibc_packet_timeout, mock_wasmd_attr, + mock_ibc_packet_ack, mock_ibc_packet_recv, mock_wasmd_attr, }; use cosmwasm_std::{ Empty, Event, IbcAcknowledgement, IbcOrder, Reply, ReplyOn, SubMsgResponse,