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

feat: add ClientStoreProvider interface for isolated prefix stores #5781

Merged
merged 1 commit into from
Jan 31, 2024

Conversation

damiannolan
Copy link
Member

Description

Adds a nice slim interface with a single method ClientStore for light client modules to retrieve a prefixed client store.

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.

  • Targeted PR against the 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 and Go style guide.
  • Wrote unit and integration tests.
  • Updated relevant documentation (docs/) or specification (x/<module>/spec/).
  • Added relevant godoc comments.
  • Provide a commit message to be used for the changelog entry in the PR description for review.
  • Re-reviewed Files changed in the Github PR explorer.
  • Review Codecov Report in the comment section below once CI passes.

@colin-axner colin-axner self-assigned this Jan 31, 2024
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!! 💯 I like this approach a lot better than passing our the ibc store key. I think it aligns well with the pr I opened to remove genesis handling from light client modules. I think the general narrative is that light client modules manage their client type prefix in the client store, but that they must request access to these stores from 02-client. 02-client in exchange will manage genesis import/export

I'm happy with the API naming, we can always revisit if someone prefers a different name

@@ -569,11 +569,11 @@ func NewSimApp(

clientRouter := app.IBCKeeper.ClientKeeper.GetRouter()

tmLightClientModule := ibctm.NewLightClientModule(appCodec, keys[ibcexported.StoreKey], authtypes.NewModuleAddress(govtypes.ModuleName).String())
Copy link
Contributor

Choose a reason for hiding this comment

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

I like this wiring, very simple

@@ -38,11 +38,11 @@ type Keeper struct {
}

// NewKeeper creates a new NewKeeper instance
func NewKeeper(cdc codec.BinaryCodec, key storetypes.StoreKey, router *types.Router, legacySubspace types.ParamSubspace, sk types.StakingKeeper, uk types.UpgradeKeeper) Keeper {
func NewKeeper(cdc codec.BinaryCodec, key storetypes.StoreKey, legacySubspace types.ParamSubspace, sk types.StakingKeeper, uk types.UpgradeKeeper) Keeper {
Copy link
Contributor

Choose a reason for hiding this comment

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

niice, I like not having to pass the router in

Copy link
Member Author

Choose a reason for hiding this comment

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

aye!! there's possibly more improvements to be made on structuring and what not but let's go with this for now

Copy link
Member Author

Choose a reason for hiding this comment

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

Could also instantiate the storeProvider here when creating the router.

)

// Keeper defines the 06-solomachine Keeper.
// TODO(damian): delete the keeper and put the codec on the LightClientModule?
Copy link
Contributor

Choose a reason for hiding this comment

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

+1 keeper may only be necessary if a msg server is added (which for solo machine I'm not sure we need)

type LightClientModule struct {
keeper keeper.Keeper
keeper keeper.Keeper
storeProvider exported.ClientStoreProvider
Copy link
Contributor

Choose a reason for hiding this comment

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

localhost we should actually just provide the full ibc store. I don't think it needs a store provider

Copy link
Member Author

Choose a reason for hiding this comment

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

indeed, lets follow up on it

@damiannolan damiannolan marked this pull request as ready for review January 31, 2024 14:33
@damiannolan damiannolan merged commit 3020f38 into feat/02-client-router Jan 31, 2024
24 of 27 checks passed
@damiannolan damiannolan deleted the damian/storekey-injection branch January 31, 2024 14:34
damiannolan added a commit that referenced this pull request Mar 14, 2024
* 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]>
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.

2 participants