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

[WIP][IBC] Implement ICS-02 Client Semantics #916

Draft
wants to merge 23 commits into
base: ibc/proto-exploration-ics23
Choose a base branch
from
Draft
Changes from 1 commit
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Use clientID prefixed client store
  • Loading branch information
h5law committed Jul 24, 2023
commit 7718b9c7759346d9c957f80a3389824940a50ce7
26 changes: 18 additions & 8 deletions ibc/client/submodule.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package client
import (
"fmt"

"github.com/pokt-network/pocket/ibc/client/types"
"github.com/pokt-network/pocket/ibc/path"
core_types "github.com/pokt-network/pocket/shared/core/types"
"github.com/pokt-network/pocket/shared/modules"
Expand All @@ -15,7 +16,7 @@ var (
)

func init() {
allowedClientTypes["08-wasm"] = struct{}{}
allowedClientTypes[types.WasmClientType] = struct{}{}
}

type clientManager struct {
Expand Down Expand Up @@ -67,8 +68,9 @@ func (c *clientManager) CreateClient(
// Generate a unique identifier for the client
identifier := path.GenerateClientIdentifier()

// Retrieve the client store
clientStore, err := c.GetBus().GetIBCHost().GetProvableStore(path.KeyClientStorePrefix)
// Retrieve the client store prefixed with the client identifier
prefixed := path.ApplyPrefix(core_types.CommitmentPrefix(path.KeyClientStorePrefix), identifier)
clientStore, err := c.GetBus().GetIBCHost().GetProvableStore(string(prefixed))
if err != nil {
return "", err
}
Expand Down Expand Up @@ -105,8 +107,9 @@ func (c *clientManager) UpdateClient(
return err
}

// Get the client store
clientStore, err := c.GetBus().GetIBCHost().GetProvableStore(path.KeyClientStorePrefix)
// Retrieve the client store prefixed with the client identifier
prefixed := path.ApplyPrefix(core_types.CommitmentPrefix(path.KeyClientStorePrefix), identifier)
clientStore, err := c.GetBus().GetIBCHost().GetProvableStore(string(prefixed))
if err != nil {
return err
}
Expand Down Expand Up @@ -138,7 +141,13 @@ func (c *clientManager) UpdateClient(
}

// Update the client
consensusHeight := clientState.UpdateState(clientStore, clientMessage)
consensusHeight, err := clientState.UpdateState(clientStore, clientMessage)
if err != nil {
c.logger.Error().Err(err).Str("identifier", identifier).
Str("height", consensusHeight.ToString()).
Msg("failed to update client state")
return err
}
c.logger.Info().Str("identifier", identifier).
Str("height", consensusHeight.ToString()).
Msg("client state updated")
Expand Down Expand Up @@ -167,8 +176,9 @@ func (c *clientManager) UpgradeClient(
return err
}

// Get the client store
clientStore, err := c.GetBus().GetIBCHost().GetProvableStore(path.KeyClientStorePrefix)
// Retrieve the client store prefixed with the client identifier
prefixed := path.ApplyPrefix(core_types.CommitmentPrefix(path.KeyClientStorePrefix), identifier)
clientStore, err := c.GetBus().GetIBCHost().GetProvableStore(string(prefixed))
if err != nil {
return err
}
Expand Down