-
Notifications
You must be signed in to change notification settings - Fork 589
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
02-client routing: remove GetLatestHeight
from ClientState
interface and add it to LightClientModule
#5866
02-client routing: remove GetLatestHeight
from ClientState
interface and add it to LightClientModule
#5866
Conversation
…light client module
Important Auto Review SkippedAuto reviews are disabled on base/target branches other than the default branch. Please add the base/target branch pattern to the list of additional branches to be reviewed in the settings. Please check the settings in the CodeRabbit UI or the To trigger a single review, invoke the Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configration File (
|
@chatton and I spent some time working on this PR today, addressing compiler errors and tests. All tests are now passing and we've added a new test helper to There is still places in which we need to cast: I think the type casting/conversions will naturally resolve themselves when we remove |
GetLatestHeight
from ClientState
interface and add it to LigthClientModule
GetLatestHeight
from ClientState
interface and add it to LightClientModule
I'm trying to understand the duplication meaning. I guess its flagging test files where some boilerplate code is duplicated. E.g. in |
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.
Going to drop my approval as default on this since I pushed a lot of commits to this PR. I've reviewed all files when working on this and think any concerns can be handled in follow ups as the diff is already quite large - but also fairly digestable considering a lot of changes are basic.
ACK from me for moving this method sooner rather than later! I also think the new test helper provides a lot of value for testing purposes and we can document that in migration notes as a follow up action item!
// TODO: This code is removed in https://github.com/cosmos/ibc-go/pull/5827 | ||
// last height of current counterparty chain must be client's latest height | ||
lastHeight := clientState.GetLatestHeight() | ||
// lastHeight := k.GetLatestHeight(ctx, clientID) | ||
|
||
if !upgradedClient.GetLatestHeight().GT(lastHeight) { | ||
return errorsmod.Wrapf(ibcerrors.ErrInvalidHeight, "upgraded client height %s must be at greater than current client height %s", | ||
upgradedClient.GetLatestHeight(), lastHeight) | ||
} | ||
// if !upgradedClient.GetLatestHeight().GT(lastHeight) { | ||
// return errorsmod.Wrapf(ibcerrors.ErrInvalidHeight, "upgraded client height %s must be at greater than current client height %s", | ||
// upgradedClient.GetLatestHeight(), lastHeight) | ||
// } |
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.
Happy to leave this and address in #5827
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.
It isn't supposed to be removed 😄 Happy to see it rectified after though
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.
Yup! For sure, just wanted to punt until this PR was merged
@@ -613,6 +611,14 @@ func (chain *TestChain) GetChannelCapability(portID, channelID string) *capabili | |||
return capability | |||
} | |||
|
|||
// GetClientLatestHeight returns the latest height for the client state with the given client identifier. | |||
// If an invalid client identifier is provided then a zero value height will be returned. | |||
func (chain *TestChain) GetClientLatestHeight(clientID string) exported.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.
I think we can change this to clienttypes.Height
return value when we remove the interface.
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.
Opened #5954.
indeed. maybe we can start by ignoring this for test files since duplication there is more acceptable, later on we could tweak it for |
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 also drop my approval ✅ Thank you very much, @damiannolan and @chatton for the work on this PR.
@@ -127,6 +128,8 @@ func QueryChannelConsensusState( | |||
|
|||
// QueryLatestConsensusState uses the channel Querier to return the | |||
// latest ConsensusState given the source port ID and source channel ID. | |||
// Deprecated: This function will be removed in a later release of ibc-go. | |||
// NOTE: This function only supports querying latest consensus state of 07-tendermint client state implementations. | |||
func QueryLatestConsensusState( |
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.
Since this function is not exposed as an RPC, probably hermes doesn't use it. And I cannot find any usage of it in the go relayer. So maybe is safe to just delete them?
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 there is consensus on this then yes, let's remove 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.
I am fine nuking it. What do you think, @colin-axner?
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.
Fine with me 👍 pr to main?
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 can tweak this. What value would be good to trigger when really needed and but avoid false positives? |
// TODO: This code is removed in https://github.com/cosmos/ibc-go/pull/5827 | ||
// last height of current counterparty chain must be client's latest height | ||
lastHeight := clientState.GetLatestHeight() | ||
// lastHeight := k.GetLatestHeight(ctx, clientID) | ||
|
||
if !upgradedClient.GetLatestHeight().GT(lastHeight) { | ||
return errorsmod.Wrapf(ibcerrors.ErrInvalidHeight, "upgraded client height %s must be at greater than current client height %s", | ||
upgradedClient.GetLatestHeight(), lastHeight) | ||
} | ||
// if !upgradedClient.GetLatestHeight().GT(lastHeight) { | ||
// return errorsmod.Wrapf(ibcerrors.ErrInvalidHeight, "upgraded client height %s must be at greater than current client height %s", | ||
// upgradedClient.GetLatestHeight(), lastHeight) | ||
// } |
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.
It isn't supposed to be removed 😄 Happy to see it rectified after though
@@ -60,7 +60,7 @@ func (suite *KeeperTestSuite) TestSetAndGetClientConnectionPaths() { | |||
} | |||
|
|||
// create 2 connections: A0 - B0, A1 - B1 | |||
func (suite KeeperTestSuite) TestGetAllConnections() { //nolint:govet // this is a test, we are okay with copying locks | |||
func (suite *KeeperTestSuite) TestGetAllConnections() { |
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.
might be nice to just pull these fixes as a pr to main since they are out of scope and could reduce diffs
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.
Happy to do that! And then rebase the feat branch for 02 router refactor when its merged, think its fine to keep em here tho
@@ -127,6 +128,8 @@ func QueryChannelConsensusState( | |||
|
|||
// QueryLatestConsensusState uses the channel Querier to return the | |||
// latest ConsensusState given the source port ID and source channel ID. | |||
// Deprecated: This function will be removed in a later release of ibc-go. | |||
// NOTE: This function only supports querying latest consensus state of 07-tendermint client state implementations. | |||
func QueryLatestConsensusState( |
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.
Fine with me 👍 pr to main?
// If no client is present for the provided client identifier a zero value height is returned. | ||
// | ||
// CONTRACT: clientID is validated in 02-client router, thus clientID is assumed here to be 09-localhost. | ||
func (lcm LightClientModule) LatestHeight(ctx sdk.Context, clientID string) exported.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.
needs a test (followup against main is fine)
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.
Let's address in localhost PR :)
// if !sdk.IsAlphaNumeric(module) { | ||
// panic(errors.New("route expressions can only contain alphanumeric characters")) | ||
// } |
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.
do we still want some of formatting check?
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.
Let's take this discussion to the feat branch PR maybe. Will take a look at it closer there :)
// prevent accidental sends with clients that cannot be updated | ||
if status := k.clientKeeper.GetClientStatus(ctx, connectionEnd.ClientId); status != exported.Active { | ||
return 0, errorsmod.Wrapf(clienttypes.ErrClientNotActive, "cannot send packet using client (%s) with status %s", connectionEnd.ClientId, status) | ||
} | ||
|
||
latestHeight := clientState.GetLatestHeight() | ||
latestHeight := k.clientKeeper.GetLatestHeight(ctx, connectionEnd.ClientId) |
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.
probably should do a latestHeight.IsZero
check here, otherwise the timeout height is disregarded:
// heightElapsed returns true if the timeout height is non empty
// and the timeout height is greater than or equal to the relative height.
func (t Timeout) heightElapsed(height clienttypes.Height) bool {
return !t.Height.IsZero() && height.GTE(t.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.
I'm not sure I follow this one, this latestHeight
var is pased to timeout.Elapsed
which performs the check you've just showed.
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.
yes, if the latest height is zero, then heightElapsed
can never return true as the latest height will never be greater than the timeout 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.
Cool, so check latestHeight.IsZero
and return error before creating the timeout
?
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.
Excellent work y'all 💪 Big thanks to @damiannolan and @chatton for muscling through this one!! Happy to see this merged, left a note on anything that stood out to me, but they can be tackled in later pr's as necessary
Feels like things are moving in a nice direction 🙂
Awesome! ❤️ I'll address some of the smaller points in a commit before merge! Happy to handle the others later :) |
…reduce disk reads
…y done in 02-client
* refactor: add initial light client module interface * wip: add boiler plate light client module for tendermint client * feat: adding initial light client module impl for 06-solomachine * chore: adding LightClientModule interface assertion for 06-solomachine * chore: adding initial boiilerplate for 08-wasm mod * refactor: add boilerplate tendermint light client module * refactor: add localhost boilerplate code * imp: add basic 02-client router * refactor: use light client module for client status * chore: move solomachine keeper to internal * chore: adding GetTimestampAtHeight to clientkeeper using 02-client router * refactor: rm GetTimestampAtHeight from 03-connection and adapt api calls in 04-channel * chore: wire up solomachine module with clientRouter in app.go * chore: move commented out test to client keeper - still has todo to uncomment and fix * chore: add solomachine client module to AppModule constructor and wire up in app.go * fix: use correct route for client status lookup * chore: add clientRouter to 08-wasm simapp and wire up * fix: solo machine unmarshal bug and 02-client keeper tests * test: fix GetTimestampAtHeight test in clientkeeper * refactor(solomachine): add getClientState helper and unmarhsal interface * refactor: align 08-wasm, add GetClientState helper and unmarshal interface * fix(temp): temporarily add WithStoreKey opt to wasmkeeper to fix failing tests * fix: wire up callbacks simapp to fix failing tests * refactor: modify UpdateClient handler to use light client module api * feat: add ClientStoreProvider interface for isolated prefix stores (#5781) * refactor: rm internal/keeper from solomachine * refactor: begin removing stale client state interfaces * feat: wire up localhost * fix: tests in 06-solomachine and 07-tendermint * fix: rest of tests * refactor: use light client module APIs in 03-connection state verify * chore: adapt remaining handlers to use light client module api in 03-connection * fix: locahost verify membership and non membership in light client module * refactor: remove VerifyMembership and VerifyNonMembership from client state interface * fix: rm getters for clientID from connection (conflict) * 02-client routing: fix linter warnings (#5818) * 02-client routing: fix linter warnings * fix variable name * return error * 02-client routing: pass client ID to get route instead of client type (#5817) * pass client ID to get route instead of client type * rename variable * Update modules/core/02-client/keeper/keeper.go --------- Co-authored-by: Damian Nolan <[email protected]> * use localhost client ID * 02-client routing: function in store provider to return client store (#5824) * add function to return 02-client module store * review comment * 02-client routing: implement `RecoverClient` in light client modules (#5822) * implement recover client in light client modules * add tests for wasm light client module recover client function * missing file * add tests for tendermint light client module recover client * add tests for solomachine light client module recover client * clean up 02-client recover client test cases * fix test * fix linter warning * format client IDs * fixes from merge of main * 02-client routing: remove client ID validation (#5897) * chore: remove client ID validation in light client module functions * add contract documentation * Update light_client_module.go * 02-client routing: add godoc to `LightClientModule` functions (#5900) * add godoc for light client module functions * linter * fix localhost client ID in godoc * docs: add removal of `ClientState` interface functions to migration docs (#5943) * docs: add removal of client state functions to migration docs * test formating * add comment about tendermint light client module implementation * Apply suggestions from code review Co-authored-by: colin axnér <[email protected]> * mention removal of ZeroCustomFields * Update docs/docs/05-migrations/13-v8-to-v9.md Co-authored-by: DimitrisJim <[email protected]> --------- Co-authored-by: colin axnér <[email protected]> Co-authored-by: DimitrisJim <[email protected]> * 02-client routing: remove `GetLatestHeight` from `ClientState` interface and add it to `LightClientModule` (#5866) * wip: remove GetLatestHeight from ClientState interface and add it to light client module * chore: add godoc for GetLatestHeight in 02-client keeper * chore: add args to event emission funcs in 02-client * chore: add args to usage in 02-client event emissions * chore: put back logging in upgrade client * chore: deprecate and refactor 04-channel client utils QueryLatestConsensusState func * chore: rename lightClientModule to clientModule in core * chore: undo faulty renames * fix: godoc for LatestHeight * chore: add godocs * chore: readding sequence checking in solomachine RecoverClient * fix: testing chain helper to use keeper getter for latest height * chore: fix compilation errors in tests * fix: import ordering waaah * imp: adding GetClientLatestHeight to testing endpoint/chain * test: cleanup test funcs with path.Endpoint.GetClientLatestHeight * test: cleanup tests in 04-channel to use path.Endpoint.GetClientLatestHeight * test: cleanup ante_test * chore: add godocs for light client modules LatestHeight method * chore: update endpoint.go to use the new GetClientLatestHeight helper fn * test: usage of path.Endpoint.GetClientLatestHeight in core/keeper and 07-tendermint tests * test: another one * chore: rm GetLatestHeight from solomachine ClientState * test: update QueryConsensusStateProof in testing lib to use test helper * Update testing/chain.go * fix typo in variable name * chore: consolidate two calls to LatestHeight to initialHeight var on createClient * chore: extract to latestHeight var in VerifyUpgradeAndUpdateState to reduce disk reads * chore: rm greater than or equal height check in solomachine as already done in 02-client * chore: address todo on GetLatestHeight in 02-client keeper --------- Co-authored-by: Damian Nolan <[email protected]> Co-authored-by: chatton <[email protected]> * docs: refactor light client developer guide * imp: cleanup godoc on router type * 02-client routing: implement `VerifyUpgradeAndUpdateState` in light client modules (#5827) * wip: implementation and tests for verify upgrade and update state function in light client modules * add test case * fix un-marshaling in tendermint light client module * add tests for verify upgrade and update state of 08-wasm light client module * fix linter warnings * check client state post upgrade * fix: encoding issue: unmarshal to concrete types and not interfaces in 07-tendermint * fix import * cast type before calling zero custom fields * test: marshal concrete types using chain codec for upgrade tests which bypass msg server entrypoint * chore: remove basic validation of lc types in tm VerifyUpgradeAndUpdateState * marshal to concrete type in tests * keep client/consensus state as interface marshalled * Apply suggestions from code review Co-authored-by: colin axnér <[email protected]> * chore: make lint-fix * chore: rm redundant test, tested in lightclient module * fix: remove marshalling of anys to bytes for verify upgrade (#5967) * fix: remove marshalling of anys to bytes for verify upgrade * test: refactor 02-client tests for verify upgrade * test: fix tests in 07-tenderint client module * chore: rm backwards compatability notice and marshalling of anys in core msg server * test: cleanup happy path assertions in 07-tendermint verify upgrade test * nit: update inline code commentin test * doc: update godoc of UpgradeClient handler in core ibc * lint: make lint-fix * nit: inline comments in tests last Height -> upgrade height * fix: address 08-wasm upgrade client and tests --------- Co-authored-by: Damian Nolan <[email protected]> Co-authored-by: colin axnér <[email protected]> * nit: lcm -> l for all light client modules * remove unnecessary comment * chore: remove unnecessary todo's * chore: lint fix docs * Apply suggestions from code review * chore: 02-client handler godoc * Update modules/core/02-client/keeper/client.go * Update modules/light-clients/06-solomachine/light_client_module_test.go * remove commented out code in msg server * chore: update godoc, remove todo's * chore: remove unnecessary func from localhost + cleanup * Apply suggestions from code review * Update docs/docs/03-light-clients/01-developer-guide/01-overview.md Co-authored-by: DimitrisJim <[email protected]> * chore: remove todo + deprecation notice * chore: fix broken link * chore: godoc for exported client.go file * chore: test update * chore: godoc * chore: update godoc in 06-solomachine light client module * chore: update 07-tendermint light client module godoc * chore: update localhost client module godocs * chore: update 08-wasm light client module godoc * fix: broken link * fix(e2e): correctly assign trusted height and latest height vars to be scoped correctly for later usage in misbehaviour test * address my self-review comments and some of rabbit's comments * Update e2e/tests/transfer/localhost_test.go * chore: godocs, rm ClientStore from expected keeper, rename events arg to initialHeight --------- Co-authored-by: Colin Axnér <[email protected]> Co-authored-by: Carlos Rodriguez <[email protected]> Co-authored-by: DimitrisJim <[email protected]> Co-authored-by: chatton <[email protected]>
Description
closes: #XXXX
Commit Message / Changelog Entry
see the guidelines for commit messages. (view raw markdown for examples)
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.Files changed
in the Github PR explorer.Codecov Report
in the comment section below once CI passes.