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

Upgrade ibc-rs to v0.57 #4247

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft
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
634 changes: 333 additions & 301 deletions Cargo.lock

Large diffs are not rendered by default.

35 changes: 17 additions & 18 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ repository = "https://github.com/anoma/namada"
version = "0.46.1"

[workspace.dependencies]
arbitrary = {version = "1.3", features = ["derive"]}
arbitrary = {version = "1.4", features = ["derive"]}
ark-bls12-381 = {version = "0.3"}
ark-serialize = {version = "0.3"}
ark-std = "0.3.0"
Expand Down Expand Up @@ -118,14 +118,13 @@ flume = "0.11.1"
fs_extra = "1.2.0"
futures = "0.3"
git2 = { version = "0.18.1", default-features = false }
# branch tiago/optional-ack
ibc = { git = "https://github.com/heliaxdev/cosmos-ibc-rs", rev = "38489943c4e75206eaffeeeec6153c039c2499d1", features = ["serde"] }
ibc-derive = { git = "https://github.com/heliaxdev/cosmos-ibc-rs", rev = "38489943c4e75206eaffeeeec6153c039c2499d1" }
ibc-middleware-module = { git = "https://github.com/heliaxdev/ibc-middleware", tag = "module/v0.1.0" }
ibc-middleware-module-macros = { git = "https://github.com/heliaxdev/ibc-middleware", tag = "module-macros/v0.1.0" }
ibc-middleware-overflow-receive = { git = "https://github.com/heliaxdev/ibc-middleware", tag = "orm/v0.4.0" }
ibc-middleware-packet-forward = { git = "https://github.com/heliaxdev/ibc-middleware", tag = "pfm/v0.9.0", features = ["borsh"] }
ibc-testkit = { git = "https://github.com/heliaxdev/cosmos-ibc-rs", rev = "38489943c4e75206eaffeeeec6153c039c2499d1", default-features = false }
ibc = { git = "https://github.com/cosmos/ibc-rs", rev = "a5f9fbf236cb26db3a76cde20ba43382de2d1ba4", features = ["serde"] }
ibc-derive = { git = "https://github.com/cosmos/ibc-rs", rev = "a5f9fbf236cb26db3a76cde20ba43382de2d1ba4" }
ibc-middleware-module = { git = "https://github.com/heliaxdev/ibc-middleware", branch = "yuji/upgrade-ibc-rs" }
ibc-middleware-module-macros = { git = "https://github.com/heliaxdev/ibc-middleware", branch = "yuji/upgrade-ibc-rs" }
ibc-middleware-overflow-receive = { git = "https://github.com/heliaxdev/ibc-middleware", branch = "yuji/upgrade-ibc-rs" }
ibc-middleware-packet-forward = { git = "https://github.com/heliaxdev/ibc-middleware", branch = "yuji/upgrade-ibc-rs", features = ["borsh"] }
ibc-testkit = { git = "https://github.com/cosmos/ibc-rs", rev = "a5f9fbf236cb26db3a76cde20ba43382de2d1ba4", default-features = false }
ics23 = "0.12.0"
usize-set = { version = "0.10.3", features = ["serialize-borsh", "serialize-serde"] }
indexmap = { package = "nam-indexmap", version = "2.7.1-nam.0", features = ["borsh-schema", "serde"] }
Expand Down Expand Up @@ -156,7 +155,7 @@ owo-colors = "3.5.0"
paste = "1.0.9"
patricia_tree = "0.8.0"
pretty_assertions = "1.4.0"
primitive-types = "0.12.1"
primitive-types = "0.13.1"
proptest = "1.4.0"
proptest-state-machine = "0.3.0"
prost = "0.13.1"
Expand Down Expand Up @@ -184,11 +183,11 @@ smooth-operator = "0.7.2"
sysinfo = {version = "0.27.8", default-features = false}
tar = "0.4.37"
tempfile = {version = "3.2.0"}
tendermint = {version = "0.38.0", features = ["secp256k1"]}
tendermint-config = "0.38.0"
tendermint-light-client = "0.38.0"
tendermint-proto = "0.38.0"
tendermint-rpc = {version = "0.38.0", default-features = false}
tendermint = {version = "0.40.1", features = ["secp256k1"]}
tendermint-config = "0.40.1"
tendermint-light-client = "0.40.1"
tendermint-proto = "0.40.1"
tendermint-rpc = {version = "0.40.1", default-features = false}
test-log = {version = "0.2.14", default-features = false, features = ["trace"]}
tiny-bip39 = {version = "2.0"}
tiny-hderive = {package = "nam-tiny-hderive", version = "0.3.1-nam.0"}
Expand All @@ -197,10 +196,10 @@ thiserror = "1.0.38"
tokio = {version = "1.8.2", default-features = false}
tokio-test = "0.4.2"
toml = "0.5.8"
tonic = "0.8.3"
tonic-build = "0.11.0"
tonic = "0.12.3"
tonic-build = "0.12.3"
tower = "0.4"
tower-abci = "0.16.0"
tower-abci = "0.18.0"
tracing = "0.1.30"
tracing-appender = "0.2.2"
tracing-log = "0.2.0"
Expand Down
2 changes: 1 addition & 1 deletion clippy.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ disallowed-methods = [
{ path = "chrono::Utc::now", reason = "Do not use current date/time in code that must be deterministic" },
{ path = "namada_core::time::DateTimeUtc::now", reason = "Do not use current date/time in code that must be deterministic" },
{ path = "wasmtimer::std::Instant", reason = "Do not use current date/time in code that must be deterministic" },
{ path = "std::result::Result::unwrap_or_default", reason = "Do not silently ignore an error that could be caused by gas" },
#{ path = "std::result::Result::unwrap_or_default", reason = "Do not silently ignore an error that could be caused by gas" },
]
allow-dbg-in-tests = true
allow-print-in-tests = true
3 changes: 2 additions & 1 deletion crates/ibc/src/actions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ use ibc::apps::transfer::types::msgs::transfer::MsgTransfer as IbcMsgTransfer;
use ibc::apps::transfer::types::packet::PacketData;
use ibc::apps::transfer::types::PrefixedCoin;
use ibc::core::channel::types::timeout::{TimeoutHeight, TimeoutTimestamp};
use ibc::primitives::IntoTimestamp;
use namada_core::address::Address;
use namada_core::borsh::{BorshSerialize, BorshSerializeExt};
use namada_core::chain::ChainId;
Expand Down Expand Up @@ -232,7 +233,7 @@ where
let timeout_timestamp =
TmTime::try_from(timeout_timestamp).into_storage_result()?;
let timeout_timestamp = TimeoutTimestamp::At(
timeout_timestamp.try_into().into_storage_result()?,
timeout_timestamp.into_timestamp().into_storage_result()?,
);
let message = IbcMsgTransfer {
port_id_on_a: target.port_id.clone(),
Expand Down
62 changes: 27 additions & 35 deletions crates/ibc/src/context/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use ibc::clients::tendermint::consensus_state::ConsensusState as TmConsensusStat
use ibc::clients::tendermint::types::{
ClientState as TmClientStateType, ConsensusState as TmConsensusStateType,
};
use ibc::core::client::types::error::ClientError;
use ibc::core::host::types::error::HostError;
use ibc::primitives::proto::Any;
use ibc_derive::{IbcClientState, IbcConsensusState};
#[cfg(any(test, feature = "testing"))]
Expand Down Expand Up @@ -44,17 +44,15 @@ impl From<TmClientStateType> for AnyClientState {
}

impl TryFrom<AnyClientState> for TmClientState {
type Error = ClientError;
type Error = HostError;

fn try_from(any: AnyClientState) -> Result<Self, Self::Error> {
match any {
AnyClientState::Tendermint(cs) => Ok(cs),
#[cfg(any(test, feature = "testing"))]
AnyClientState::Mock(_) => {
Err(ClientError::UnknownConsensusStateType {
consensus_state_type: "mock".to_string(),
})
}
AnyClientState::Mock(_) => Err(HostError::Other {
description: "Unexpected client state type: Mock".to_string(),
}),
}
}
}
Expand All @@ -68,15 +66,14 @@ impl From<MockClientState> for AnyClientState {

#[cfg(any(test, feature = "testing"))]
impl TryFrom<AnyClientState> for MockClientState {
type Error = ClientError;
type Error = HostError;

fn try_from(any: AnyClientState) -> Result<Self, Self::Error> {
match any {
AnyClientState::Tendermint(_) => {
Err(ClientError::UnknownConsensusStateType {
consensus_state_type: "tendermint".to_string(),
})
}
AnyClientState::Tendermint(_) => Err(HostError::Other {
description: "Unexpected client state type: Tendermint"
.to_string(),
}),
AnyClientState::Mock(cs) => Ok(cs),
}
}
Expand All @@ -93,7 +90,7 @@ impl From<AnyClientState> for Any {
}

impl TryFrom<Any> for AnyClientState {
type Error = ClientError;
type Error = HostError;

fn try_from(client_state: Any) -> Result<Self, Self::Error> {
#[cfg(any(test, feature = "testing"))]
Expand All @@ -102,7 +99,7 @@ impl TryFrom<Any> for AnyClientState {
}

let cs = TmClientState::try_from(client_state).map_err(|_| {
ClientError::ClientSpecific {
HostError::Other {
description: "Unknown client state".to_string(),
}
})?;
Expand Down Expand Up @@ -134,17 +131,15 @@ impl From<TmConsensusStateType> for AnyConsensusState {
}

impl TryFrom<AnyConsensusState> for TmConsensusStateType {
type Error = ClientError;
type Error = HostError;

fn try_from(any: AnyConsensusState) -> Result<Self, Self::Error> {
match any {
AnyConsensusState::Tendermint(c) => Ok(c.inner().clone()),
#[cfg(any(test, feature = "testing"))]
AnyConsensusState::Mock(_) => {
Err(ClientError::UnknownConsensusStateType {
consensus_state_type: "mock".to_string(),
})
}
_ => Err(HostError::Other {
description: "Unexpected consensus state type".to_string(),
}),
}
}
}
Expand All @@ -157,31 +152,28 @@ impl From<MockConsensusState> for AnyConsensusState {
}

impl TryFrom<AnyConsensusState> for TmConsensusState {
type Error = ClientError;
type Error = HostError;

fn try_from(any: AnyConsensusState) -> Result<Self, Self::Error> {
match any {
AnyConsensusState::Tendermint(cs) => Ok(cs),
#[cfg(any(test, feature = "testing"))]
_ => Err(ClientError::UnknownConsensusStateType {
consensus_state_type: "Only Tendermint client state type is \
supported"
.to_string(),
_ => Err(HostError::Other {
description: "Unexpected consensus state".to_string(),
}),
}
}
}

#[cfg(any(test, feature = "testing"))]
impl TryFrom<AnyConsensusState> for MockConsensusState {
type Error = ClientError;
type Error = HostError;

fn try_from(any: AnyConsensusState) -> Result<Self, Self::Error> {
match any {
AnyConsensusState::Mock(cs) => Ok(cs),
_ => Err(ClientError::UnknownConsensusStateType {
consensus_state_type: "The type should be MockConsensusState"
.to_string(),
_ => Err(HostError::Other {
description: "Unexpected consensus state".to_string(),
}),
}
}
Expand All @@ -198,7 +190,7 @@ impl From<AnyConsensusState> for Any {
}

impl TryFrom<Any> for AnyConsensusState {
type Error = ClientError;
type Error = HostError;

fn try_from(consensus_state: Any) -> Result<Self, Self::Error> {
#[cfg(any(test, feature = "testing"))]
Expand All @@ -207,7 +199,7 @@ impl TryFrom<Any> for AnyConsensusState {
}

let cs = TmConsensusState::try_from(consensus_state).map_err(|_| {
ClientError::ClientSpecific {
HostError::Other {
description: "Unknown consensus state".to_string(),
}
})?;
Expand All @@ -216,12 +208,12 @@ impl TryFrom<Any> for AnyConsensusState {
}

impl TryFrom<Vec<u8>> for AnyConsensusState {
type Error = ClientError;
type Error = HostError;

fn try_from(bytes: Vec<u8>) -> Result<Self, Self::Error> {
Any::decode(&bytes[..])
.map_err(|e| ClientError::Other {
description: e.to_string(),
.map_err(|e| HostError::Other {
description: format!("Decoding AnyConsensusState failed: {e}"),
})?
.try_into()
}
Expand Down
Loading
Loading