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

[2.0] Remove old ibc-v1 #1875

Merged
merged 5 commits into from
Nov 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions MIGRATING.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand Down
17 changes: 12 additions & 5 deletions contracts/ibc-reflect-send/src/ibc.rs
Original file line number Diff line number Diff line change
@@ -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::{
Expand All @@ -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<IbcChannelOpenResponse> {
let channel = msg.channel();

if channel.order != IbcOrder::Ordered {
Expand All @@ -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]
Expand Down
2 changes: 1 addition & 1 deletion contracts/ibc-reflect/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"] }

Expand Down
1 change: 0 additions & 1 deletion docs/USING_COSMWASM_STD.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 |
Expand Down
2 changes: 1 addition & 1 deletion packages/go-gen/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
5 changes: 1 addition & 4 deletions packages/std/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand All @@ -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 = []
Expand Down
7 changes: 3 additions & 4 deletions packages/std/src/exports.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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")]
Expand Down Expand Up @@ -529,7 +529,6 @@ where
query_fn(deps.as_ref(), env, msg).into()
}

#[cfg(feature = "stargate")]
fn _do_ibc_channel_open<Q, E>(
contract_fn: &dyn Fn(DepsMut<Q>, Env, IbcChannelOpenMsg) -> Result<IbcChannelOpenResponse, E>,
env_ptr: *mut Region,
Expand Down
33 changes: 3 additions & 30 deletions packages/std/src/ibc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -299,11 +298,9 @@ impl From<IbcChannelOpenMsg> 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<Ibc3ChannelOpenResponse>;
chipshort marked this conversation as resolved.
Show resolved Hide resolved

#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)]
Expand Down Expand Up @@ -405,17 +402,10 @@ impl From<IbcChannelCloseMsg> 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 }
}
Expand All @@ -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,
Expand All @@ -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 }
}
Expand Down
7 changes: 4 additions & 3 deletions packages/std/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down
10 changes: 2 additions & 8 deletions packages/std/src/testing/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,6 @@ pub fn mock_ibc_packet_recv(
}
.into(),
},
#[cfg(feature = "ibc3")]
Addr::unchecked("relayer"),
))
}
Expand Down Expand Up @@ -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<IbcPacketTimeoutMsg> {
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
Expand Down
2 changes: 1 addition & 1 deletion packages/vm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion packages/vm/src/calls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Loading