-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
Conversation
Codecov Report
@@ 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 |
There was a problem hiding this 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 |
There was a problem hiding this comment.
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()) |
There was a problem hiding this comment.
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())) |
There was a problem hiding this comment.
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?
There was a problem hiding this 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.
uint64 height = 3; | ||
ibc.client.Height height = 3 [ | ||
(gogoproto.moretags) = "yaml:\"height\"", | ||
(gogoproto.nullable) = false |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
// 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; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why this option?
There was a problem hiding this comment.
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
chain-id's will be forced to follow a specific format like appending |
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. |
As mentioned above, currently hardcoding epoch-number as 0 for now. Will retrieve from chain-id in future PR |
There was a problem hiding this 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
Description
This is part 1 of addressing #6531
It accomplishes the following:
02-client/exported
client/proto
07-tendermint
client and09-localhost
What this PR does not do:
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 theEpochHeight
) in all IBC interfacesBefore 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.
docs/
) or specification (x/<module>/spec/
)godoc
comments.Unreleased
section inCHANGELOG.md
Files changed
in the Github PR explorerCodecov Report
in the comment section below once CI passes