Skip to content

Commit

Permalink
Update to tendermint 0.26 (#208)
Browse files Browse the repository at this point in the history
* Update to tendermint 0.26

* Fix no-std-check with a temporary patch

* Post-merge updates for tendermint 0.26

* ics04_channel::events: Use Option::map_or_else

Option::map_or requires the alternative value to be non-lazily
constructed, so we save some allocations.

* Update ibc-proto to 0.22.0

* Rename TimeoutHeight::to_attribute_value

Ramify the name as to_event_attribute_value for clarity.

* Unpin tendermint version

tendermint-rs is now committed to fully following Rust semver
conventions.

* Convert ClientIdAttribute like the rest of them

* Changelog entry for #208

* connection events: remove an outdated comment

* Derive derive_more::Into for ClientId
  • Loading branch information
mzabaluev authored Nov 16, 2022
1 parent 9b7f4f4 commit 69babe1
Show file tree
Hide file tree
Showing 14 changed files with 230 additions and 319 deletions.
2 changes: 2 additions & 0 deletions .changelog/unreleased/breaking-changes/208-tendermint-0.26.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- Update to tendermint-rs 0.26 and ibc-proto 0.22
([#208](https://github.com/cosmos/ibc-rs/issues/208))
21 changes: 12 additions & 9 deletions ci/no-std-check/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 4 additions & 7 deletions ci/no-std-check/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ resolver = "2"

[dependencies]
ibc = { path = "../../crates/ibc", default-features = false }
ibc-proto = { version = "0.20.1", default-features = false }
tendermint = { version = "0.25.0", default-features = false }
tendermint-proto = { version = "0.25.0", default-features = false }
tendermint-light-client-verifier = { version = "0.25.0", default-features = false }
ibc-proto = { version = "0.22.0", default-features = false }
tendermint = { version = "0.26.0", default-features = false }
tendermint-proto = { version = "0.26.0", default-features = false }
tendermint-light-client-verifier = { version = "0.26.0", default-features = false }

sp-core = { version = "5.0.0", default-features = false, optional = true }
sp-io = { version = "5.0.0", default-features = false, optional = true }
Expand All @@ -30,6 +30,3 @@ substrate-std = [
"sp-runtime/std",
"sp-std/std",
]

[patch.crates-io]
ibc-proto = { git = "https://github.com/cosmos/ibc-proto-rs", branch = "main" }
14 changes: 7 additions & 7 deletions crates/ibc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ mocks = ["tendermint-testgen", "clock", "std"]

[dependencies]
# Proto definitions for all IBC-related interfaces, e.g., connections or channels.
ibc-proto = { version = "0.21.0", default-features = false }
ibc-proto = { version = "0.22.0", default-features = false }
ics23 = { version = "=0.8.1", default-features = false, features = ["host-functions"] }
time = { version = ">=0.3.0, <0.3.17", default-features = false }
serde_derive = { version = "1.0.104", default-features = false }
Expand All @@ -48,19 +48,19 @@ primitive-types = { version = "0.12.0", default-features = false, features = ["s
dyn-clone = "1.0.8"

[dependencies.tendermint]
version = "=0.25.0"
version = "0.26.0"
default-features = false

[dependencies.tendermint-proto]
version = "=0.25.0"
version = "0.26.0"
default-features = false

[dependencies.tendermint-light-client-verifier]
version = "=0.25.0"
version = "0.26.0"
default-features = false

[dependencies.tendermint-testgen]
version = "=0.25.0"
version = "0.26.0"
optional = true
default-features = false

Expand All @@ -70,5 +70,5 @@ tracing-subscriber = { version = "0.3.14", features = ["fmt", "env-filter", "jso
test-log = { version = "0.2.10", features = ["trace"] }
modelator = "0.4.2"
sha2 = { version = "0.10.6" }
tendermint-rpc = { version = "=0.25.0", features = ["http-client", "websocket-client"] }
tendermint-testgen = { version = "=0.25.0" } # Needed for generating (synthetic) light blocks.
tendermint-rpc = { version = "0.26.0", features = ["http-client", "websocket-client"] }
tendermint-testgen = { version = "0.26.0" } # Needed for generating (synthetic) light blocks.
69 changes: 27 additions & 42 deletions crates/ibc/src/core/ics02_client/events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
use derive_more::From;
use ibc_proto::google::protobuf::Any;
use subtle_encoding::hex;
use tendermint::abci::tag::Tag;
use tendermint::abci::Event as AbciEvent;
use tendermint::abci;

use crate::core::ics02_client::client_type::ClientType;
use crate::core::ics02_client::height::Height;
Expand All @@ -31,12 +30,9 @@ struct ClientIdAttribute {
client_id: ClientId,
}

impl From<ClientIdAttribute> for Tag {
impl From<ClientIdAttribute> for abci::EventAttribute {
fn from(attr: ClientIdAttribute) -> Self {
Tag {
key: CLIENT_ID_ATTRIBUTE_KEY.parse().unwrap(),
value: attr.client_id.to_string().parse().unwrap(),
}
(CLIENT_ID_ATTRIBUTE_KEY, attr.client_id.as_str()).into()
}
}

Expand All @@ -45,12 +41,9 @@ struct ClientTypeAttribute {
client_type: ClientType,
}

impl From<ClientTypeAttribute> for Tag {
impl From<ClientTypeAttribute> for abci::EventAttribute {
fn from(attr: ClientTypeAttribute) -> Self {
Tag {
key: CLIENT_TYPE_ATTRIBUTE_KEY.parse().unwrap(),
value: attr.client_type.to_string().parse().unwrap(),
}
(CLIENT_TYPE_ATTRIBUTE_KEY, attr.client_type.as_str()).into()
}
}

Expand All @@ -59,12 +52,9 @@ struct ConsensusHeightAttribute {
consensus_height: Height,
}

impl From<ConsensusHeightAttribute> for Tag {
impl From<ConsensusHeightAttribute> for abci::EventAttribute {
fn from(attr: ConsensusHeightAttribute) -> Self {
Tag {
key: CONSENSUS_HEIGHT_ATTRIBUTE_KEY.parse().unwrap(),
value: attr.consensus_height.to_string().parse().unwrap(),
}
(CONSENSUS_HEIGHT_ATTRIBUTE_KEY, attr.consensus_height).into()
}
}

Expand All @@ -73,17 +63,14 @@ struct ConsensusHeightsAttribute {
consensus_heights: Vec<Height>,
}

impl From<ConsensusHeightsAttribute> for Tag {
impl From<ConsensusHeightsAttribute> for abci::EventAttribute {
fn from(attr: ConsensusHeightsAttribute) -> Self {
let consensus_heights: Vec<String> = attr
.consensus_heights
.into_iter()
.map(|consensus_height| consensus_height.to_string())
.collect();
Tag {
key: CONSENSUS_HEIGHTS_ATTRIBUTE_KEY.parse().unwrap(),
value: consensus_heights.join(",").parse().unwrap(),
}
(CONSENSUS_HEIGHTS_ATTRIBUTE_KEY, consensus_heights.join(",")).into()
}
}

Expand All @@ -92,15 +79,13 @@ struct HeaderAttribute {
header: Any,
}

impl From<HeaderAttribute> for Tag {
impl From<HeaderAttribute> for abci::EventAttribute {
fn from(attr: HeaderAttribute) -> Self {
Tag {
key: HEADER_ATTRIBUTE_KEY.parse().unwrap(),
value: String::from_utf8(hex::encode(attr.header.value))
.unwrap()
.parse()
.unwrap(),
}
(
HEADER_ATTRIBUTE_KEY,
String::from_utf8(hex::encode(attr.header.value)).unwrap(),
)
.into()
}
}

Expand Down Expand Up @@ -134,10 +119,10 @@ impl CreateClient {
}
}

impl From<CreateClient> for AbciEvent {
impl From<CreateClient> for abci::Event {
fn from(c: CreateClient) -> Self {
AbciEvent {
type_str: IbcEventType::CreateClient.as_str().to_string(),
Self {
kind: IbcEventType::CreateClient.as_str().to_owned(),
attributes: vec![
c.client_id.into(),
c.client_type.into(),
Expand Down Expand Up @@ -197,10 +182,10 @@ impl UpdateClient {
}
}

impl From<UpdateClient> for AbciEvent {
impl From<UpdateClient> for abci::Event {
fn from(u: UpdateClient) -> Self {
AbciEvent {
type_str: IbcEventType::UpdateClient.as_str().to_string(),
Self {
kind: IbcEventType::UpdateClient.as_str().to_owned(),
attributes: vec![
u.client_id.into(),
u.client_type.into(),
Expand Down Expand Up @@ -237,10 +222,10 @@ impl ClientMisbehaviour {
}
}

impl From<ClientMisbehaviour> for AbciEvent {
impl From<ClientMisbehaviour> for abci::Event {
fn from(c: ClientMisbehaviour) -> Self {
AbciEvent {
type_str: IbcEventType::ClientMisbehaviour.as_str().to_string(),
Self {
kind: IbcEventType::ClientMisbehaviour.as_str().to_owned(),
attributes: vec![c.client_id.into(), c.client_type.into()],
}
}
Expand Down Expand Up @@ -276,10 +261,10 @@ impl UpgradeClient {
}
}

impl From<UpgradeClient> for AbciEvent {
impl From<UpgradeClient> for abci::Event {
fn from(u: UpgradeClient) -> Self {
AbciEvent {
type_str: IbcEventType::UpgradeClient.as_str().to_string(),
Self {
kind: IbcEventType::UpgradeClient.as_str().to_owned(),
attributes: vec![
u.client_id.into(),
u.client_type.into(),
Expand Down
Loading

0 comments on commit 69babe1

Please sign in to comment.