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

Update to tendermint 0.26 #208

Merged
merged 14 commits into from
Nov 16, 2022
Merged
Show file tree
Hide file tree
Changes from 4 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
3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,6 @@ members = [
exclude = [
"ci/no-std-check",
]

[patch.crates-io]
hu55a1n1 marked this conversation as resolved.
Show resolved Hide resolved
ibc-proto = { git = "https://github.com/cosmos/ibc-proto-rs.git", rev = "2cf514366768ddef257db3283a0b8bcb4bf9638a" }
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.

10 changes: 5 additions & 5 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.21.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 @@ -32,4 +32,4 @@ substrate-std = [
]

[patch.crates-io]
ibc-proto = { git = "https://github.com/cosmos/ibc-proto-rs", branch = "main" }
ibc-proto = { git = "https://github.com/cosmos/ibc-proto-rs.git", rev = "2cf514366768ddef257db3283a0b8bcb4bf9638a" }
12 changes: 6 additions & 6 deletions crates/ibc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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.
71 changes: 30 additions & 41 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,11 +30,12 @@ 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(),
Self {
key: CLIENT_ID_ATTRIBUTE_KEY.to_owned(),
value: attr.client_id.into(),
index: false,
}
}
}
Expand All @@ -45,12 +45,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()
}
}
Comment on lines +44 to 48
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that the EventAttribute domain type also has an index field, which is set to false by the From conversion used here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, it may have been too early to switch to tendermint::abci::Event before informalsystems/tendermint-rs#1204 is released. There is still tendermint_rpc::abci::Event confusingly, but it's what hermes is using.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Upon further examination, the ABCI event infrastructure in Hermes now duplicates this code and is not dependent on ibc. So we can go on with this change.


Expand All @@ -59,12 +56,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 +67,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 +83,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 +123,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 +186,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 +226,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 +265,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