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

fix: use Vec<u8> for header attribute instead of Any #766

Merged
merged 2 commits into from
Jul 14, 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
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- Use Vec<u8> for HeaderAttribute instead of Any
([#764](https://github.com/cosmos/ibc-rs/issues/764))
11 changes: 5 additions & 6 deletions crates/ibc/src/core/ics02_client/events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
use crate::prelude::*;

use derive_more::From;
use ibc_proto::google::protobuf::Any;
use subtle_encoding::hex;
use tendermint::abci;

Expand Down Expand Up @@ -147,14 +146,14 @@ impl From<ConsensusHeightsAttribute> for abci::EventAttribute {
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[derive(Clone, Debug, From, PartialEq, Eq)]
struct HeaderAttribute {
header: Any,
header: Vec<u8>,
}

impl From<HeaderAttribute> for abci::EventAttribute {
fn from(attr: HeaderAttribute) -> Self {
(
HEADER_ATTRIBUTE_KEY,
String::from_utf8(hex::encode(attr.header.value))
String::from_utf8(hex::encode(attr.header))
.expect("Never fails because hexadecimal is valid UTF-8"),
)
.into()
Expand Down Expand Up @@ -252,7 +251,7 @@ impl UpdateClient {
client_type: ClientType,
consensus_height: Height,
consensus_heights: Vec<Height>,
header: Any,
header: Vec<u8>,
) -> Self {
Self {
client_id: ClientIdAttribute::from(client_id),
Expand All @@ -279,7 +278,7 @@ impl UpdateClient {
self.consensus_heights.consensus_heights.as_ref()
}

pub fn header(&self) -> &Any {
pub fn header(&self) -> &Vec<u8> {
&self.header.header
}

Expand Down Expand Up @@ -471,7 +470,7 @@ mod tests {
client_type.clone(),
consensus_height,
consensus_heights,
header,
header.value,
)
.into(),
expected_keys: expected_keys.clone(),
Expand Down
4 changes: 2 additions & 2 deletions crates/ibc/src/core/ics02_client/handler/update_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ where
client_state.client_type(),
*consensus_height,
consensus_heights,
header,
header.value,
))
};
ctx.emit_ibc_event(IbcEvent::Message(MessageEvent::Client));
Expand Down Expand Up @@ -488,7 +488,7 @@ mod tests {
assert_eq!(update_client_event.client_type(), &mock_client_type());
assert_eq!(update_client_event.consensus_height(), &height);
assert_eq!(update_client_event.consensus_heights(), &vec![height]);
assert_eq!(update_client_event.header(), &header);
assert_eq!(update_client_event.header(), &header.value);
}

fn ensure_misbehaviour(ctx: &MockContext, client_id: &ClientId, client_type: &ClientType) {
Expand Down