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

Make clients use proto Height #7184

Merged
merged 14 commits into from
Aug 31, 2020
Merged

Make clients use proto Height #7184

merged 14 commits into from
Aug 31, 2020

Conversation

AdityaSripal
Copy link
Member

Description

This is part 1 of addressing #6531

It accomplishes the following:

  • create a Height interface in 02-client/exported
  • create concrete implementation in client/proto
  • Use concrete implementation in internal state of 07-tendermint client and 09-localhost

What this PR does not do:

  • Change all core IBC interfaces (02/03/04/24) to use the abstract Height implementation
  • Retrieve epoch number from chain ID

These will be addressed in subsequent PRs. So effectively the clients that need epoch numbers now use them under the hood, but they still only return uint64 (namely the EpochHeight) in all IBC interfaces


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

@codecov
Copy link

codecov bot commented Aug 27, 2020

Codecov Report

Merging #7184 into master will increase coverage by 0.00%.
The diff coverage is 77.00%.

@@           Coverage Diff           @@
##           master    #7184   +/-   ##
=======================================
  Coverage   54.77%   54.77%           
=======================================
  Files         563      564    +1     
  Lines       38612    38661   +49     
=======================================
+ Hits        21148    21177   +29     
- Misses      15733    15752   +19     
- Partials     1731     1732    +1     

Copy link
Collaborator

@fedekunze fedekunze left a comment

Choose a reason for hiding this comment

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

LGTM. How we are going to check the epoch from the chain-id? I noticed that there are a few places where the epoch is hardcoded to 0 due to that TODO.

@@ -43,7 +43,11 @@ func InitGenesis(ctx sdk.Context, k keeper.Keeper, gs types.GenesisState) {
}

// client id is always "localhost"
clientState := localhosttypes.NewClientState(ctx.ChainID(), ctx.BlockHeight())
// Hardcode 0 as epoch number for now
// TODO: Retrieve epoch from chain-id
Copy link
Collaborator

Choose a reason for hiding this comment

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

track issue?

@@ -71,9 +72,10 @@ func (h Header) ValidateBasic(chainID string) error {

// TrustedHeight is less than Header for updates
// and less than or equal to Header for misbehaviour
if h.TrustedHeight > h.GetHeight() {
height := clienttypes.NewHeight(0, h.GetHeight())
Copy link
Collaborator

Choose a reason for hiding this comment

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

should we check the epoch from the chain-id here too?

@@ -96,7 +96,7 @@ func (cs ClientState) CheckMisbehaviourAndUpdateState(
return nil, sdkerrors.Wrap(err, "verifying Header2 in Misbehaviour failed")
}

cs.FrozenHeight = uint64(tmEvidence.GetHeight())
cs.FrozenHeight = clienttypes.NewHeight(0, uint64(tmEvidence.GetHeight()))
Copy link
Collaborator

Choose a reason for hiding this comment

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

ditto epoch from header chain id?

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, only requesting changes since I think there was one semantic change in tendermint.

I'd also prefer if we added LTE and GTE for readability.

proto/ibc/localhost/localhost.proto Outdated Show resolved Hide resolved
uint64 height = 3;
ibc.client.Height height = 3 [
(gogoproto.moretags) = "yaml:\"height\"",
(gogoproto.nullable) = false
Copy link
Contributor

Choose a reason for hiding this comment

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

does this need to be a pointer for proto?

Copy link
Member Author

Choose a reason for hiding this comment

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

Would this be a problem for proto encoding/decoding? Given the choice, i prefer it to not be a pointer since there's no reason to have a nil Height for ClientState/ConsensusState and not having nil checks everywhere is simpler

proto/ibc/tendermint/tendermint.proto Outdated Show resolved Hide resolved
// In these cases, the epoch number is incremented so that height continues to be monitonically increasing
// even as the EpochHeight gets reset
message Height {
option (gogoproto.goproto_stringer) = false;
Copy link
Contributor

Choose a reason for hiding this comment

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

why this option?

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 want to be able to define my own String() method on Height, especially since it will eventually go into host.ConsensusStatePath

x/ibc/02-client/types/height.go Outdated Show resolved Hide resolved
x/ibc/07-tendermint/types/misbehaviour_handle_test.go Outdated Show resolved Hide resolved
x/ibc/07-tendermint/types/misbehaviour_handle.go Outdated Show resolved Hide resolved
x/ibc/07-tendermint/types/misbehaviour_handle.go Outdated Show resolved Hide resolved
x/ibc/07-tendermint/types/misbehaviour.go Outdated Show resolved Hide resolved
x/ibc/02-client/types/height.go Outdated Show resolved Hide resolved
@colin-axner
Copy link
Contributor

How we are going to check the epoch from the chain-id?

chain-id's will be forced to follow a specific format like appending -<epochnumber> to their chain-id

@fedekunze
Copy link
Collaborator

chain-id's will be forced to follow a specific format like appending - to their chain-id

note that won't work for Ethermint as the EVM requires an integer for chain-id

@colin-axner
Copy link
Contributor

note that won't work for Ethermint as the EVM requires an integer for chain-id

cc/ @cwgoes

@cwgoes
Copy link
Contributor

cwgoes commented Aug 28, 2020

note that won't work for Ethermint as the EVM requires an integer for chain-id

cc/ @cwgoes

Hmm, we can just parse the integer instead, I suppose. This is a bit of a hack but since Tendermint doesn't natively support epochs we have to put the epoch number in something which will be signed-over.

@AdityaSripal
Copy link
Member Author

As mentioned above, currently hardcoding epoch-number as 0 for now. Will retrieve from chain-id in future PR

@fedekunze fedekunze requested a review from colin-axner August 28, 2020 20:28
Copy link
Contributor

@cwgoes cwgoes left a comment

Choose a reason for hiding this comment

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

ACK modulo follow-ups

@AdityaSripal AdityaSripal added the A:automerge Automatically merge PR once all prerequisites pass. label Aug 31, 2020
@mergify mergify bot merged commit d208d2b into master Aug 31, 2020
@mergify mergify bot deleted the aditya/proto-height branch August 31, 2020 17:57
@AdityaSripal AdityaSripal mentioned this pull request Sep 15, 2020
9 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A:automerge Automatically merge PR once all prerequisites pass.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants