Skip to content

Commit

Permalink
ibc-types: bump prost, tendermint, ibc-proto, ics23 (#94)
Browse files Browse the repository at this point in the history
Updates the following dependencies:
+ ibc-proto: 0.42.2 -> 0.51.1
+ ics23: 0.11.3 -> 0.12.0
+ prost: 0.12.0 -> 0.13.3
+ tendermint: 0.34.0 -> 0.40.0
+ tendermint-light-client-verifier: 0.34.0 -> 0.40.0
+ tendermint-proto: 0.34.0 -> 0.40.0
+ tendermint-rpc: 0.34.0 -> 0.40.0
+ tendermint-testgen: 0.34.0 -> 0.40.0

The bump to the latest tendermint version required bumping prost, which
in turns required updates of ibc-proto and ics23 (where I opted for
their latest releases, respectively).

The two larger changes are:

1. From [email protected] onward conversions between
`core::time::Duration` and `protobuf.google.Duration` are now fallible.
I introduced a newtype wrapper `CometBftDuration` to restore the
previous behavior saturating at `i64::MAX` (for seconds) and `i32::MAX`
(for nanos), respectively.
2. From `[email protected]` onward
[`tendermint::abci::EventAttribute`](https://docs.rs/tendermint/0.36.0/tendermint/abci/enum.EventAttribute.html)
became an enum with variants `V037` and `V034`, and introduced the
fallible accessors `EventAttribute::key_str` and
`EventAttribute::value_str`, in addition to the infallible
`EventAttribute::key_bytes` and `EventAttribute::value_bytes`. This
required changes in many `TryFrom<Event>` impls that would previously
match on `&str` keys and directly move (or parse) `String` values. I
chose to avoid extra error handling, instead matching on byte-string
using `value_bytes()` (e.g. now `b"packet_src_channel" => {}` instead of
the previous `"packet_src_channel" => {}`), and relying on
`String::from_utf8_lossy` for the values.
  • Loading branch information
SuperFluffy authored Dec 7, 2024
1 parent 4cd8fc0 commit 0abbaeb
Show file tree
Hide file tree
Showing 17 changed files with 819 additions and 493 deletions.
12 changes: 6 additions & 6 deletions crates/ibc-types-core-channel/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -60,19 +60,19 @@ ibc-types-domain-type = { version = "0.14.1", path = "../ibc-types-domain-type",
ibc-types-identifier = { version = "0.14.1", path = "../ibc-types-identifier", default-features = false }
ibc-types-timestamp = { version = "0.14.1", path = "../ibc-types-timestamp", default-features = false }
# Proto definitions for all IBC-related interfaces, e.g., connections or channels.
ibc-proto = { version = "0.42.2", default-features = false }
ibc-proto = { version = "0.51.1", default-features = false }
## for borsh encode or decode
borsh = {version = "0.10.0", default-features = false, optional = true }
bytes = { version = "1.2.1", default-features = false }
cfg-if = { version = "1.0.0", optional = true }
derive_more = { version = "0.99.17", default-features = false, features = ["from", "into", "display"] }
displaydoc = { version = "0.2", default-features = false }
ics23 = { version = "0.11.3", default-features = false, features = ["host-functions"] }
ics23 = { version = "0.12.0", default-features = false, features = ["host-functions"] }
num-traits = { version = "0.2.15", default-features = false }
## for codec encode or decode
parity-scale-codec = { version = "3.0.0", default-features = false, features = ["full"], optional = true }
parking_lot = { version = "0.12.1", default-features = false, optional = true }
prost = { version = "0.12", default-features = false }
prost = { version = "0.13.3", default-features = false }
safe-regex = { version = "0.2.5", default-features = false }
# proc-macro2 to unbreak docs.rs build, see GH#56
proc-macro2 = { version = "0.1", default-features = false }
Expand All @@ -87,15 +87,15 @@ scale-info = { version = "2.1.2", default-features = false, features = ["derive"
anyhow = { version = "1", default-features = false }

[dependencies.tendermint]
version = "0.34.0"
version = "0.40.0"
default-features = false

[dependencies.tendermint-proto]
version = "0.34.0"
version = "0.40.0"
default-features = false

[dependencies.tendermint-testgen]
version = "0.34.0"
version = "0.40.0"
optional = true
default-features = false

Expand Down
214 changes: 139 additions & 75 deletions crates/ibc-types-core-channel/src/events/channel.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use alloc::borrow::ToOwned;
use ibc_types_core_connection::ConnectionId;
use tendermint::abci::{Event, TypedEvent};

use crate::prelude::*;
use crate::{ChannelId, PortId, Version};

use super::Error;
Expand Down Expand Up @@ -56,23 +56,32 @@ impl TryFrom<Event> for OpenInit {
let mut version = None;

for attr in event.attributes {
match attr.key.as_ref() {
"port_id" => {
port_id = Some(PortId(attr.value));
match attr.key_bytes() {
b"port_id" => {
port_id = Some(PortId(String::from_utf8_lossy(attr.value_bytes()).into()));
}
"channel_id" => {
channel_id = Some(ChannelId(attr.value));
b"channel_id" => {
channel_id = Some(ChannelId(
String::from_utf8_lossy(attr.value_bytes()).into(),
));
}
"counterparty_port_id" => {
counterparty_port_id = Some(PortId(attr.value));
b"counterparty_port_id" => {
counterparty_port_id =
Some(PortId(String::from_utf8_lossy(attr.value_bytes()).into()));
}
"connection_id" => {
connection_id = Some(ConnectionId(attr.value));
b"connection_id" => {
connection_id = Some(ConnectionId(
String::from_utf8_lossy(attr.value_bytes()).into(),
));
}
"version" => {
version = Some(Version(attr.value));
b"version" => {
version = Some(Version(String::from_utf8_lossy(attr.value_bytes()).into()));
}
unknown => {
return Err(Error::UnexpectedAttribute(
String::from_utf8_lossy(unknown).into(),
))
}
unknown => return Err(Error::UnexpectedAttribute(unknown.to_owned())),
}
}

Expand Down Expand Up @@ -136,26 +145,37 @@ impl TryFrom<Event> for OpenTry {
let mut version = None;

for attr in event.attributes {
match attr.key.as_ref() {
"port_id" => {
port_id = Some(PortId(attr.value));
match attr.key_bytes() {
b"port_id" => {
port_id = Some(PortId(String::from_utf8_lossy(attr.value_bytes()).into()));
}
b"channel_id" => {
channel_id = Some(ChannelId(
String::from_utf8_lossy(attr.value_bytes()).into(),
));
}
"channel_id" => {
channel_id = Some(ChannelId(attr.value));
b"counterparty_port_id" => {
counterparty_port_id =
Some(PortId(String::from_utf8_lossy(attr.value_bytes()).into()));
}
"counterparty_port_id" => {
counterparty_port_id = Some(PortId(attr.value));
b"counterparty_channel_id" => {
counterparty_channel_id = Some(ChannelId(
String::from_utf8_lossy(attr.value_bytes()).into(),
));
}
"counterparty_channel_id" => {
counterparty_channel_id = Some(ChannelId(attr.value));
b"connection_id" => {
connection_id = Some(ConnectionId(
String::from_utf8_lossy(attr.value_bytes()).into(),
));
}
"connection_id" => {
connection_id = Some(ConnectionId(attr.value));
b"version" => {
version = Some(Version(String::from_utf8_lossy(attr.value_bytes()).into()));
}
"version" => {
version = Some(Version(attr.value));
unknown => {
return Err(Error::UnexpectedAttribute(
String::from_utf8_lossy(unknown).into(),
))
}
unknown => return Err(Error::UnexpectedAttribute(unknown.to_owned())),
}
}

Expand Down Expand Up @@ -218,23 +238,34 @@ impl TryFrom<Event> for OpenAck {
let mut connection_id = None;

for attr in event.attributes {
match attr.key.as_ref() {
"port_id" => {
port_id = Some(PortId(attr.value));
match attr.key_bytes() {
b"port_id" => {
port_id = Some(PortId(String::from_utf8_lossy(attr.value_bytes()).into()));
}
b"channel_id" => {
channel_id = Some(ChannelId(
String::from_utf8_lossy(attr.value_bytes()).into(),
));
}
"channel_id" => {
channel_id = Some(ChannelId(attr.value));
b"counterparty_port_id" => {
counterparty_port_id =
Some(PortId(String::from_utf8_lossy(attr.value_bytes()).into()));
}
"counterparty_port_id" => {
counterparty_port_id = Some(PortId(attr.value));
b"counterparty_channel_id" => {
counterparty_channel_id = Some(ChannelId(
String::from_utf8_lossy(attr.value_bytes()).into(),
));
}
"counterparty_channel_id" => {
counterparty_channel_id = Some(ChannelId(attr.value));
b"connection_id" => {
connection_id = Some(ConnectionId(
String::from_utf8_lossy(attr.value_bytes()).into(),
));
}
"connection_id" => {
connection_id = Some(ConnectionId(attr.value));
unknown => {
return Err(Error::UnexpectedAttribute(
String::from_utf8_lossy(unknown).into(),
))
}
unknown => return Err(Error::UnexpectedAttribute(unknown.to_owned())),
}
}

Expand Down Expand Up @@ -296,23 +327,34 @@ impl TryFrom<Event> for OpenConfirm {
let mut connection_id = None;

for attr in event.attributes {
match attr.key.as_ref() {
"port_id" => {
port_id = Some(PortId(attr.value));
match attr.key_bytes() {
b"port_id" => {
port_id = Some(PortId(String::from_utf8_lossy(attr.value_bytes()).into()));
}
"channel_id" => {
channel_id = Some(ChannelId(attr.value));
b"channel_id" => {
channel_id = Some(ChannelId(
String::from_utf8_lossy(attr.value_bytes()).into(),
));
}
"counterparty_port_id" => {
counterparty_port_id = Some(PortId(attr.value));
b"counterparty_port_id" => {
counterparty_port_id =
Some(PortId(String::from_utf8_lossy(attr.value_bytes()).into()));
}
"counterparty_channel_id" => {
counterparty_channel_id = Some(ChannelId(attr.value));
b"counterparty_channel_id" => {
counterparty_channel_id = Some(ChannelId(
String::from_utf8_lossy(attr.value_bytes()).into(),
));
}
"connection_id" => {
connection_id = Some(ConnectionId(attr.value));
b"connection_id" => {
connection_id = Some(ConnectionId(
String::from_utf8_lossy(attr.value_bytes()).into(),
));
}
unknown => {
return Err(Error::UnexpectedAttribute(
String::from_utf8_lossy(unknown).into(),
))
}
unknown => return Err(Error::UnexpectedAttribute(unknown.to_owned())),
}
}

Expand Down Expand Up @@ -374,23 +416,34 @@ impl TryFrom<Event> for CloseInit {
let mut connection_id = None;

for attr in event.attributes {
match attr.key.as_ref() {
"port_id" => {
port_id = Some(PortId(attr.value));
match attr.key_bytes() {
b"port_id" => {
port_id = Some(PortId(String::from_utf8_lossy(attr.value_bytes()).into()));
}
b"channel_id" => {
channel_id = Some(ChannelId(
String::from_utf8_lossy(attr.value_bytes()).into(),
));
}
"channel_id" => {
channel_id = Some(ChannelId(attr.value));
b"counterparty_port_id" => {
counterparty_port_id =
Some(PortId(String::from_utf8_lossy(attr.value_bytes()).into()));
}
"counterparty_port_id" => {
counterparty_port_id = Some(PortId(attr.value));
b"counterparty_channel_id" => {
counterparty_channel_id = Some(ChannelId(
String::from_utf8_lossy(attr.value_bytes()).into(),
));
}
"counterparty_channel_id" => {
counterparty_channel_id = Some(ChannelId(attr.value));
b"connection_id" => {
connection_id = Some(ConnectionId(
String::from_utf8_lossy(attr.value_bytes()).into(),
));
}
"connection_id" => {
connection_id = Some(ConnectionId(attr.value));
unknown => {
return Err(Error::UnexpectedAttribute(
String::from_utf8_lossy(unknown).into(),
))
}
unknown => return Err(Error::UnexpectedAttribute(unknown.to_owned())),
}
}

Expand Down Expand Up @@ -452,23 +505,34 @@ impl TryFrom<Event> for CloseConfirm {
let mut connection_id = None;

for attr in event.attributes {
match attr.key.as_ref() {
"port_id" => {
port_id = Some(PortId(attr.value));
match attr.key_bytes() {
b"port_id" => {
port_id = Some(PortId(String::from_utf8_lossy(attr.value_bytes()).into()));
}
b"channel_id" => {
channel_id = Some(ChannelId(
String::from_utf8_lossy(attr.value_bytes()).into(),
));
}
"channel_id" => {
channel_id = Some(ChannelId(attr.value));
b"counterparty_port_id" => {
counterparty_port_id =
Some(PortId(String::from_utf8_lossy(attr.value_bytes()).into()));
}
"counterparty_port_id" => {
counterparty_port_id = Some(PortId(attr.value));
b"counterparty_channel_id" => {
counterparty_channel_id = Some(ChannelId(
String::from_utf8_lossy(attr.value_bytes()).into(),
));
}
"counterparty_channel_id" => {
counterparty_channel_id = Some(ChannelId(attr.value));
b"connection_id" => {
connection_id = Some(ConnectionId(
String::from_utf8_lossy(attr.value_bytes()).into(),
));
}
"connection_id" => {
connection_id = Some(ConnectionId(attr.value));
unknown => {
return Err(Error::UnexpectedAttribute(
String::from_utf8_lossy(unknown).into(),
))
}
unknown => return Err(Error::UnexpectedAttribute(unknown.to_owned())),
}
}

Expand Down
Loading

0 comments on commit 0abbaeb

Please sign in to comment.