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

Remove ClientType func and update consensus state path #7573

Merged
merged 12 commits into from
Oct 19, 2020
3 changes: 0 additions & 3 deletions x/ibc/core/02-client/simulation/decoder.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,6 @@ func NewDecodeStore(cdc ClientUnmarshaler, kvA, kvB kv.Pair) (string, bool) {
clientStateB := cdc.MustUnmarshalClientState(kvB.Value)
return fmt.Sprintf("ClientState A: %v\nClientState B: %v", clientStateA, clientStateB), true

case bytes.HasPrefix(kvA.Key, host.KeyClientStorePrefix) && bytes.HasSuffix(kvA.Key, host.KeyClientType()):
return fmt.Sprintf("Client type A: %s\nClient type B: %s", string(kvA.Value), string(kvB.Value)), true

case bytes.HasPrefix(kvA.Key, host.KeyClientStorePrefix) && bytes.Contains(kvA.Key, []byte("consensusState")):
consensusStateA := cdc.MustUnmarshalConsensusState(kvA.Value)
consensusStateB := cdc.MustUnmarshalConsensusState(kvB.Value)
Expand Down
6 changes: 0 additions & 6 deletions x/ibc/core/02-client/simulation/decoder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import (
"github.com/cosmos/cosmos-sdk/x/ibc/core/02-client/types"
host "github.com/cosmos/cosmos-sdk/x/ibc/core/24-host"
ibctmtypes "github.com/cosmos/cosmos-sdk/x/ibc/light-clients/07-tendermint/types"
ibctesting "github.com/cosmos/cosmos-sdk/x/ibc/testing"
)

func TestDecodeStore(t *testing.T) {
Expand All @@ -36,10 +35,6 @@ func TestDecodeStore(t *testing.T) {
Key: host.FullKeyClientPath(clientID, host.KeyClientState()),
Value: app.IBCKeeper.ClientKeeper.MustMarshalClientState(clientState),
},
{
Key: host.FullKeyClientPath(clientID, host.KeyClientType()),
Value: []byte(ibctesting.Tendermint),
},
{
Key: host.FullKeyClientPath(clientID, host.KeyConsensusState(height)),
Value: app.IBCKeeper.ClientKeeper.MustMarshalConsensusState(consState),
Expand All @@ -55,7 +50,6 @@ func TestDecodeStore(t *testing.T) {
expectedLog string
}{
{"ClientState", fmt.Sprintf("ClientState A: %v\nClientState B: %v", clientState, clientState)},
{"client type", fmt.Sprintf("Client type A: %s\nClient type B: %s", ibctesting.Tendermint, ibctesting.Tendermint)},
{"ConsensusState", fmt.Sprintf("ConsensusState A: %v\nConsensusState B: %v", consState, consState)},
{"other", ""},
}
Expand Down
13 changes: 1 addition & 12 deletions x/ibc/core/24-host/keys.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,28 +64,17 @@ func ClientStatePath() string {
return "clientState"
}

// ClientTypePath takes an Identifier and returns Path under which to store the
// type of a particular client.
func ClientTypePath() string {
return "clientType"
}

// ConsensusStatePath takes an Identifier and returns a Path under which to
// store the consensus state of a client.
func ConsensusStatePath(height exported.Height) string {
return fmt.Sprintf("consensusState/%s", height)
return fmt.Sprintf("consensusStates/%s", height)
}

// KeyClientState returns the store key for a particular client state
func KeyClientState() []byte {
return []byte(ClientStatePath())
}

// KeyClientType returns the store key for type of a particular client
func KeyClientType() []byte {
return []byte(ClientTypePath())
}

// KeyConsensusState returns the store key for the consensus state of a particular
// client
func KeyConsensusState(height exported.Height) []byte {
Expand Down
4 changes: 2 additions & 2 deletions x/ibc/core/spec/02_state.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ a prefix to the path to be able to aggregate the values for querying purposes.

| Prefix | Path | Value type |
|--------|------------------------------------------------------------------------|----------------|
| "0/" | "clients/{identifier}" | ClientState |
| "0/" | "clients/{identifier}/consensusState/{height}" | ConsensusState |
| "0/" | "clients/{identifier}/clientState" | ClientState |
| "0/" | "clients/{identifier}/consensusStates/{height}" | ConsensusState |
| "0/" | "clients/{identifier}/type" | ClientType |
| "0/" | "connections/{identifier}" | ConnectionEnd |
| "0/" | "ports/{identifier}" | CapabilityKey |
Expand Down