Skip to content

Commit

Permalink
update client selection
Browse files Browse the repository at this point in the history
  • Loading branch information
mkaczanowski committed Jun 14, 2021
1 parent addc5d2 commit 10ea5ce
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
14 changes: 12 additions & 2 deletions modules/core/02-client/types/params.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,13 @@ var (
// DefaultAllowedClients are "06-solomachine" and "07-tendermint"
DefaultAllowedClients = []string{exported.Solomachine, exported.Tendermint}

DefaultWASMClientEnabled = false
// DefaultWasmClientsEnabled is false
DefaultWasmClientsEnabled = false

// KeyAllowedClients is store's key for AllowedClients Params
KeyAllowedClients = []byte("AllowedClients")

// KeyWasmClientsEnabled indicates whether Wasm light clients are allowed
KeyWasmClientsEnabled = []byte("WasmClientsEnabled")
)

Expand All @@ -35,7 +37,7 @@ func NewParams(wasmClientEnabled bool, allowedClients ...string) Params {

// DefaultParams is the default parameter configuration for the ibc-client module
func DefaultParams() Params {
return NewParams(DefaultWASMClientEnabled, DefaultAllowedClients...)
return NewParams(DefaultWasmClientsEnabled, DefaultAllowedClients...)
}

// Validate all ibc-client module parameters
Expand All @@ -58,6 +60,10 @@ func (p *Params) ParamSetPairs() paramtypes.ParamSetPairs {

// IsAllowedClient checks if the given client type is registered on the allowlist.
func (p Params) IsAllowedClient(clientType string) bool {
if p.WasmClientsEnabled && isWasmClient(clientType) {
return true
}

for _, allowedClient := range p.AllowedClients {
if allowedClient == clientType {
return true
Expand Down Expand Up @@ -89,3 +95,7 @@ func validateClients(i interface{}) error {

return nil
}

func isWasmClient(clientType string) bool {
return strings.HasPrefix(clientType, exported.WasmClientPrefix)
}
3 changes: 3 additions & 0 deletions modules/core/exported/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ const (
// TypeClientMisbehaviour is the shared evidence misbehaviour type
TypeClientMisbehaviour string = "client_misbehaviour"

// WasmClientPrefix is used to indicate that the client is a on-chain Wasm blob.
WasmClientPrefix string = "wasm-"

// Solomachine is used to indicate that the light client is a solo machine.
Solomachine string = "06-solomachine"

Expand Down

0 comments on commit 10ea5ce

Please sign in to comment.