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

chore: remove GetHeight from ClientMessage interface #1285

Merged

Conversation

damiannolan
Copy link
Member

@damiannolan damiannolan commented Apr 21, 2022

Description

  • Removing the GetHeight interface method from ClientMessage.
  • Returning a list of heights []exported.Height from the new UpdateState interface.
  • Enforce checking len(consensusHeights) to guard against index out of range errors on no-op updates
  • Adding new event key AttributeKeyConsensusHeights and returning a comma separated list of consensus heights

closes: #594


Before we can merge this PR, please make sure that all the following items have been
checked off. If any of the checklist items are not applicable, please leave them but
write a little note why.

  • Targeted PR against correct branch (see CONTRIBUTING.md)
  • Linked to Github issue with discussion and accepted design OR link to spec that describes this work.
  • Code follows the module structure standards.
  • Wrote unit and integration tests
  • Updated relevant documentation (docs/) or specification (x/<module>/spec/)
  • Added relevant godoc comments.
  • Added a relevant changelog entry to the Unreleased section in CHANGELOG.md
  • Re-reviewed Files changed in the Github PR explorer
  • Review Codecov Report in the comment section below once CI passes

Copy link
Contributor

@colin-axner colin-axner left a comment

Choose a reason for hiding this comment

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

LGTM! My only concern is around handling duplicate updates. Probably best to just decide on our ideal solution and then see how it breaks relayers (and then revert if necessary)

modules/core/exported/client.go Outdated Show resolved Hide resolved
modules/light-clients/06-solomachine/types/update.go Outdated Show resolved Hide resolved
modules/light-clients/06-solomachine/types/update_test.go Outdated Show resolved Hide resolved
modules/light-clients/07-tendermint/types/update.go Outdated Show resolved Hide resolved
modules/core/02-client/types/events.go Show resolved Hide resolved
modules/core/02-client/keeper/events.go Outdated Show resolved Hide resolved
ctx.EventManager().EmitEvents(sdk.Events{
sdk.NewEvent(
types.EventTypeUpdateClient,
sdk.NewAttribute(types.AttributeKeyClientID, clientID),
sdk.NewAttribute(types.AttributeKeyClientType, clientType),
sdk.NewAttribute(types.AttributeKeyConsensusHeight, consensusHeight.String()),
sdk.NewAttribute(types.AttributeKeyConsensusHeight, consensusHeights[0].String()),
Copy link
Contributor

Choose a reason for hiding this comment

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

hmm, I think we need a len(consensusHeights) > 0 check

Copy link
Member Author

Choose a reason for hiding this comment

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

This was being checked in the UpdateClient() method of keeper.go.

if len(consensusHeights) != 0 {
    // emit events, otherwise no-op & return nil
}

return nil

Copy link
Contributor

Choose a reason for hiding this comment

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

ah yes. The only strange part is that this function assumes you pass in a non empty array of consensus heights

Unrelated, could we add // deprecated next to the consensus height attribute

Copy link
Contributor

Choose a reason for hiding this comment

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

Should we backport consensusHeights attribute to older releases? That way relayers could switch to it without waiting for all chains to upgrade to this version

Copy link
Member Author

@damiannolan damiannolan Apr 26, 2022

Choose a reason for hiding this comment

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

The only strange part is that this function assumes you pass in a non empty array of consensus heights

Agree, it is kind of strange. I'll adapt to check len(consensusHeights) inside event emission func and remove the check from the UpdateClient keeper method.

Should we backport consensusHeights attribute to older releases?

Sounds like a good idea, but this would require a separate PR to main, correct?

Edit: I'll also add deprecated comment in-line 👍 Now that I'm looking at this once again, AttributeKeyConsensusHeight is used for create and upgrade events as a single height value, and should probably be maintained. In which case, I think the deprecation notice should only be here, solely for the update events and not in types/events.go

Copy link
Contributor

Choose a reason for hiding this comment

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

good catch!


k.Logger(ctx).Info("client state updated", "client-id", clientID, "height", consensusHeight.String())
if len(consensusHeights) != 0 {
Copy link
Contributor

Choose a reason for hiding this comment

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

I think not emitting UpdateClientEvent on a successful MsgUpdateClient is problematic. I may be wrong though. Would be good to check with relayers what the best expected functionality is for dup updates

The main odd thing is if you query for UpdateClient events, this message wouldn't come up. To me, it'd make more sense if the event was emitted, but indicated it was a duplicate update

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm happy to change this to return the height from the ClientState implementation on duplicate updates.
However, I don't think we can provide information about duplicate updates in the events, that would only be possible if emitting from 07-tendermint for example, but as we discussed before they should be emitted from 02-client in a somewhat standardised fashion.

If we're in agreement, I can update this PR to return the height on duplicates and also make the changes to remove the error return value and panic instead.

Wdyt?

Copy link
Contributor

Choose a reason for hiding this comment

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

I was thinking if consensus_heights is empty, we should just return "" in the consensus heights attribute. Thoughts?

In favor of removing error return 👍

Copy link
Member Author

Choose a reason for hiding this comment

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

I updated and removed the error return, and also returning the height on duplicate header updates from 07!

Copy link
Contributor

@colin-axner colin-axner left a comment

Choose a reason for hiding this comment

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

LGTM. I still have some reservations about not emitting events for successful MsgUpdateClient which the light client does not return consensus heights for. Naturally, it makes more sense to me to emit event which indicates that result (since otherwise if you query via events, this message cannot be retrieved).

ctx.EventManager().EmitEvents(sdk.Events{
sdk.NewEvent(
types.EventTypeUpdateClient,
sdk.NewAttribute(types.AttributeKeyClientID, clientID),
sdk.NewAttribute(types.AttributeKeyClientType, clientType),
sdk.NewAttribute(types.AttributeKeyConsensusHeight, consensusHeight.String()),
sdk.NewAttribute(types.AttributeKeyConsensusHeight, consensusHeights[0].String()),
Copy link
Contributor

Choose a reason for hiding this comment

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

ah yes. The only strange part is that this function assumes you pass in a non empty array of consensus heights

Unrelated, could we add // deprecated next to the consensus height attribute

ctx.EventManager().EmitEvents(sdk.Events{
sdk.NewEvent(
types.EventTypeUpdateClient,
sdk.NewAttribute(types.AttributeKeyClientID, clientID),
sdk.NewAttribute(types.AttributeKeyClientType, clientType),
sdk.NewAttribute(types.AttributeKeyConsensusHeight, consensusHeight.String()),
sdk.NewAttribute(types.AttributeKeyConsensusHeight, consensusHeights[0].String()),
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we backport consensusHeights attribute to older releases? That way relayers could switch to it without waiting for all chains to upgrade to this version

Copy link
Contributor

@colin-axner colin-axner left a comment

Choose a reason for hiding this comment

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

Excellent! Thanks for following up on my suggestion. I think the previous solution was a great one, but I think this makes more sense given the history of how the SDK is used

@damiannolan
Copy link
Member Author

Excellent! Thanks for following up on my suggestion. I think the previous solution was a great one, but I think this makes more sense given the history of how the SDK is used

Totally agree, I think we got to the best possible solution anyways! Thanks for the discussions and reviews 👍

@damiannolan damiannolan merged commit cf893c2 into 02-client-refactor Apr 27, 2022
@damiannolan damiannolan deleted the damian/594-remove-clientmsg-get-height branch April 27, 2022 13:10
oshorefueled pushed a commit to ComposableFi/ibc-go that referenced this pull request Aug 9, 2022
* adding new consensus heights return value from UpdateState interface, updating 02-client events emission

* removing GetHeight() from ClientMessage interface, updating tests

* updating godocs to include returned consensus height data

* removing unused event emission func, adding deprecation notice, removing GetHeight from solomachine Header, updating tests

* removing error return from UpdateState, returning height on duplicate header update

* updating event emissions as per suggestions
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.

3 participants