-
Notifications
You must be signed in to change notification settings - Fork 624
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: add GetTimestampAtHeight to client state #888
Conversation
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.
Thanks for this PR, @notbdu!
@@ -39,6 +39,20 @@ func (cs ClientState) GetLatestHeight() exported.Height { | |||
return clienttypes.NewHeight(0, cs.Sequence) | |||
} | |||
|
|||
// GetTimestampAtHeight returns 0. |
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.
Is this comment correct? The implementation seems to indicate that a non-zero timestamp could also be returned...
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.
Ah, forgot to update the comment here... 🤦♂️
) (uint64, error) { | ||
consensusState, err := GetConsensusState(clientStore, cdc, height) | ||
if err != nil { | ||
return 0, err |
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.
Is there a reason not to return the error wrapped like you do for the tendermint client (i.e. sdkerrors.Wrapf(err, "height (%s)", height,)
)?
b964d7d
to
01fd5a3
Compare
Thanks for the pr's @notbdu. I might have forgotten to mention that we plan to merge all the 02-client changes into a separate feature branch. It still needs to be created, but I can make it now. Would you mind changing the target branch to it? |
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.
Nice start! Main requested changes is in relation to the solo machine
modules/light-clients/06-solomachine/types/client_state_test.go
Outdated
Show resolved
Hide resolved
Codecov Report
@@ Coverage Diff @@
## 02-client-refactor #888 +/- ##
======================================================
+ Coverage 79.85% 79.86% +0.01%
======================================================
Files 150 150
Lines 10803 10819 +16
======================================================
+ Hits 8627 8641 +14
- Misses 1752 1754 +2
Partials 424 424
|
This is ready for another pass btw! |
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 but would like a review from @colin-axner.
Thanks for the great work 🤝
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.
Fantastic work! Really appreciated the clean tests. There's small fix regarding solo machines.
Could you add a changelog entry as well? Thanks again!
if !cs.GetLatestHeight().EQ(height) { | ||
return 0, sdkerrors.Wrapf(ErrInvalidSequence, "not latest height (%s)", height) | ||
} |
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.
this can be removed. The solo machine only has a single consensus state (the latest consensus state). This function is used when checking if a packet has timed out, so we want to compare the packet timestamp against the latest consensus state, as this would be the consensus state used process the timeout proof
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.
Actually on further consideration, we should return an error if the height passed in is not associated with an expected proof height of cs.GetLatestHeight().Increment()
15544bf
to
dcec344
Compare
Thanks for the review! I just rebased and pushed. |
cdc codec.BinaryCodec, | ||
height exported.Height, | ||
) (uint64, error) { | ||
if !cs.GetLatestHeight().Increment().EQ(height) { |
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.
if !cs.GetLatestHeight().Increment().EQ(height) { | |
if !cs.GetLatestHeight().EQ(height) { |
Sorry I was incorrect!
The solo machine stores the current sequence of the next proof it'll verify. In the timeout case it'll either be verifying absence of next seq recv (ordered channels) or packet receipt absence (unordered channels). I'm not sure why I got mixed up, but the sequence is incremented after verifying and this function is always called before verifying. So the height passed in should match the current sequence. The only time it won't is during connection handshake verification which doesn't need to rely on GetTimestampAtHeight
Co-authored-by: Bo Du <[email protected]>
closed by #1659 |
Co-authored-by: Bo Du <[email protected]>
Closes: cosmos#887 Copy parts of [share package](https://github.com/celestiaorg/celestia-app/tree/main/pkg/shares) relating to compact shares. We plan to later extract common code into a separate repo that both `celestia-app` and `rollkit` can use. Changes needed to this code for use in rollkit will be handled in a later PR. Also, extracts parts needed to resolve dependencies, specifically, `namespace`, `appconsts`, and `testfactory.
Description
Add the GetTimetstampAtHeight to each client state + unit tests
PR 1/2 for: #876
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.
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