-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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
Use separate prefix store for each client #5850
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.
The store keys need to be changed (in all instances I think), we don't want to duplicate the client identifier.
Also, the tests fail locally, not sure what's up with CI - failing tests should be expected anyways, as all of the paths for proofs will need to change. I suggest separate functions for calculating store keys & then prefixing them with a client identifier, which should also be used in the verification code (e.g. verifyClientConsensusState
et al.)
Also note my question on this issue, which is relevant - cosmos/ibc#387 (comment). |
…os-sdk into aditya/prefix-client
@@ -205,8 +205,9 @@ func (suite *KeeperTestSuite) TestConnOpenAck() { | |||
connectionKey := ibctypes.KeyConnection(testConnectionIDB) | |||
proofTry, proofHeight := queryProof(suite.chainB, connectionKey) | |||
|
|||
consensusKey := ibctypes.KeyConsensusState(testClientIDA, uint64(consensusHeight)) | |||
consensusKey := append([]byte(testClientIDA+"/"), ibctypes.KeyConsensusState(uint64(consensusHeight))...) |
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.
unnecessary conversion (from unconvert
)
@@ -115,7 +115,7 @@ func (suite *KeeperTestSuite) TestConnOpenTry() { | |||
connectionKey := ibctypes.KeyConnection(testConnectionIDA) | |||
proofInit, proofHeight := queryProof(suite.chainA, connectionKey) | |||
|
|||
consensusKey := ibctypes.KeyConsensusState(testClientIDB, consensusHeight) | |||
consensusKey := prefixedClientKey(testClientIDB, ibctypes.KeyConsensusState(uint64(consensusHeight))) |
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.
unnecessary conversion (from unconvert
)
@@ -205,7 +205,7 @@ func (suite *KeeperTestSuite) TestConnOpenAck() { | |||
connectionKey := ibctypes.KeyConnection(testConnectionIDB) | |||
proofTry, proofHeight := queryProof(suite.chainB, connectionKey) | |||
|
|||
consensusKey := ibctypes.KeyConsensusState(testClientIDA, uint64(consensusHeight)) | |||
consensusKey := prefixedClientKey(testClientIDA, ibctypes.KeyConsensusState(uint64(consensusHeight))) |
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.
unnecessary conversion (from unconvert
)
@@ -66,7 +66,7 @@ func (suite *KeeperTestSuite) TestVerifyClientConsensusState() { | |||
|
|||
// TODO: is this the right consensus height | |||
consensusHeight := uint64(suite.chainA.Header.Height) | |||
consensusKey := ibctypes.KeyConsensusState(testClientIDA, consensusHeight) | |||
consensusKey := prefixedClientKey(testClientIDA, ibctypes.KeyConsensusState(uint64(consensusHeight))) |
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.
unnecessary conversion (from unconvert
)
@@ -44,7 +44,7 @@ func QueryClientState( | |||
) (types.StateResponse, error) { | |||
req := abci.RequestQuery{ | |||
Path: "store/ibc/key", | |||
Data: ibctypes.KeyClientState(clientID), | |||
Data: ibctypes.KeyClientState(), |
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 file need to be fixed to still prefix clientID
@@ -115,7 +115,7 @@ func (suite *KeeperTestSuite) TestConnOpenTry() { | |||
connectionKey := ibctypes.KeyConnection(testConnectionIDA) | |||
proofInit, proofHeight := queryProof(suite.chainA, connectionKey) | |||
|
|||
consensusKey := ibctypes.KeyConsensusState(testClientIDB, consensusHeight) | |||
consensusKey := prefixedClientKey(testClientIDB, ibctypes.KeyConsensusState(uint64(consensusHeight))) |
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.
Currently using this helper function rather than creating a prefix and using ApplyPrefix
@@ -114,7 +114,8 @@ func (cs ClientState) VerifyClientConsensusState( | |||
proof commitmentexported.Proof, | |||
consensusState clientexported.ConsensusState, | |||
) error { | |||
path, err := commitmenttypes.ApplyPrefix(prefix, ibctypes.ConsensusStatePath(counterpartyClientIdentifier, consensusHeight)) | |||
clientPrefixedPath := counterpartyClientIdentifier + "/" + ibctypes.ConsensusStatePath(consensusHeight) |
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.
Simply appending here rather than using ApplyPrefix
since the Prefix that gets used by all paths is simply ibc
. Not sure if i should create a seperate Prefix object for ClientConsensusState
and pass it in here or if I should continue hardcoding this append
If I create a prefix, I must have some code in the caller that does something like:
ibcPrefix := prefix.Bytes()
clientPrefix := commitment.NewPrefix(append(ibcPrefix, counterPartyClientID....)
// pass in clientPrefix to VerifyClientConsensusState, ibcPrefix into VerifyConnectionState
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 from the perspective of the spec the full path just needs to be correct, I'm not sure what's considered more ergonomic in the SDK.
x/ibc/02-client/keeper/keeper.go
Outdated
@@ -147,6 +148,7 @@ func (k Keeper) GetSelfConsensusState(ctx sdk.Context, height uint64) (exported. | |||
// objects. For each State object, cb will be called. If the cb returns true, | |||
// the iterator will close and stop. | |||
func (k Keeper) IterateClients(ctx sdk.Context, cb func(exported.ClientState) bool) { | |||
// TODO: determine how to fix this function with new key format |
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.
Unsure of best way to fix this function with current key format that puts clientID before "client_state"
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 should only be called outside of the state machine (e.g. in queriers), so I think it's OK if it's not the most efficient (note that all clients should still be prefixed by client/{clientID}
, so you shouldn't need to iterate over other things).
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.
Hmm currently think clientstates are stored under ibc/{clientID}/client_state
and consensus states are stored under ibc/{clientID}/consensus_state/{height}
Could add another client prefix in after ibc? then we would be iterating over client states and consensus states. would be somewhat inefficient but not terrible
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 - it should be ibc/clients/{clientID}/client_state
and ibc/clients/{clientID}/consensus_state/{height}
, I think
Closing in favor of #5980 since it was too annoying to try and rebase to master |
Closes: #5502
Description
Creates prefix store with prefix of clientID for each client instance.
Test case on 04-channel was failing. Fixed it by simply changing the expected value to match actual
For contributor use:
docs/
) or specification (x/<module>/spec/
)godoc
comments.Unreleased
section inCHANGELOG.md
Files changed
in the Github PR explorerFor admin use:
WIP
,R4R
,docs
, etc)