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

Remove height information from IbcEvent #2542

Merged
merged 32 commits into from
Aug 12, 2022

Conversation

plafer
Copy link
Contributor

@plafer plafer commented Aug 9, 2022

Closes: #2539

Description

  • Removes height() and set_height() from IbcEvent
  • In the relayer, replaces uses of IbcEvent that needed height information with new IbcEventWithHeight
  • We still use the extract_attributes_from_tx() in the TryFrom<&AbciEvent> for IbcEventStruct temporarily. All client events don't have the same attributes, so we need a different solution. Similarly for connection and channel events.

PR author checklist:

  • Added changelog entry, using unclog.
  • Added tests: integration (for Hermes) or unit/mock tests (for modules).
  • Linked to GitHub issue.
  • Updated code comments and documentation (e.g., docs/).
  • Tagged one reviewer who will be the one responsible for shepherding this PR.

Reviewer checklist:

  • Reviewed Files changed in the GitHub PR explorer.
  • Manually tested (in case integration/unit/mock tests are absent).

@plafer plafer marked this pull request as ready for review August 11, 2022 01:04
Copy link
Member

@romac romac left a comment

Choose a reason for hiding this comment

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

Great work @plafer, left some minor comments inline.

Err(Error::missing_raw_header())
}

#[cfg(test)]
Copy link
Member

Choose a reason for hiding this comment

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

Sweet!

pub const CONN_ID_ATTRIBUTE_KEY: &str = "connection_id";
pub const CLIENT_ID_ATTRIBUTE_KEY: &str = "client_id";
pub const COUNTERPARTY_CONN_ID_ATTRIBUTE_KEY: &str = "counterparty_connection_id";
pub const COUNTERPARTY_CLIENT_ID_ATTRIBUTE_KEY: &str = "counterparty_client_id";

#[derive(Debug, Deserialize, Serialize, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[derive(Debug, Default, Deserialize, Serialize, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
Copy link
Member

Choose a reason for hiding this comment

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

Nice!

Self { event, height }
}

pub fn event(&self) -> &IbcEvent {
Copy link
Member

Choose a reason for hiding this comment

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

We don't need those if the fields are public imho

Copy link
Member

Choose a reason for hiding this comment

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

Alternatively, we can make the the fields private.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

&self.event
}

pub fn height(&self) -> &Height {
Copy link
Member

Choose a reason for hiding this comment

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

Same 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.

PrettyEvents(
dst_tx_events
.iter()
.map(|ev| ev.event.clone())
Copy link
Member

Choose a reason for hiding this comment

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

Is there no way around cloning all the events here? Feel free to disregard

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Member

@hu55a1n1 hu55a1n1 left a comment

Choose a reason for hiding this comment

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

Thanks, @plafer! Nicely done! 🙏 Just added a question and a suggestion.

modules/src/events.rs Outdated Show resolved Hide resolved
@@ -336,59 +411,6 @@ impl IbcEvent {
}
}

pub fn height(&self) -> Height {
Copy link
Member

Choose a reason for hiding this comment

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

👌

relayer/src/event/rpc.rs Outdated Show resolved Hide resolved
relayer/src/event/rpc.rs Outdated Show resolved Hide resolved
Copy link
Member

@hu55a1n1 hu55a1n1 left a comment

Choose a reason for hiding this comment

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

Awesome work! Pre-approved (pending Ci fix).

@plafer plafer merged commit 996405c into master Aug 12, 2022
@plafer plafer deleted the plafer/2539-remove-ibcevent-height branch August 12, 2022 16:34
hu55a1n1 pushed a commit to hu55a1n1/hermes that referenced this pull request Sep 13, 2022
* Introduce IbcEventWithHeight

* Remove IbcEvent height() and set_height()

* before AbciEvent -> Attributes refactor

* stop using try_from_tx in favor of IbcEvent::try_from

* Client TryFrom AbciEvent done

* TryFrom AbciEvent for connection

* AbciEvent -> IbcEvent scaffolding done

* Client Abci conversion done

* connection abci -> IbcEvent done

* channel abci conversion done

* Before TxSyncResult use IbcEventWithHeight

* Remove client height

* Remove height from connection

* channel heights removed

* Move tests to modules

* move connection tests to modules

* move channel tests to modules

* fix bug

* changelog

* Update .changelog/unreleased/improvements/2542-remove-ibcevent-height

Co-authored-by: Romain Ruetschi <romain@informal.systems>

* fix potential regression

* Remove `event()` from IbcEventWithHeight

* Remove `height()` from IbcEventWithHeight

* Fix PrettyEvents

* fix regression - try 2

* cargo doc fix

* move AbciEvent -> IbcEvent to relayer

* Move abci_event -> ibc_event logic to relayer informalsystems#2

* Fix get_all_events()

* fix e2e tests

Co-authored-by: Romain Ruetschi <romain@informal.systems>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Remove height() from IbcEvent
3 participants