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

imp: return Unauthorised if code hash is not stored #5102

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
6 changes: 5 additions & 1 deletion modules/light-clients/08-wasm/types/client_state.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,12 @@ func (cs ClientState) Validate() error {
// A frozen client will become expired, so the Frozen status
// has higher precedence.
func (cs ClientState) Status(ctx sdk.Context, clientStore storetypes.KVStore, _ codec.BinaryCodec) exported.Status {
payload := QueryMsg{Status: &StatusMsg{}}
// Return unauthorized if the code hash hasn't been previously stored via storeWasmCode.
if !HasCodeHash(ctx, cs.CodeHash) {
return exported.Unauthorized
}

payload := QueryMsg{Status: &StatusMsg{}}
result, err := wasmQuery[StatusResult](ctx, clientStore, &cs, payload)
if err != nil {
return exported.Unknown
Expand Down
9 changes: 9 additions & 0 deletions modules/light-clients/08-wasm/types/client_state_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (

storetypes "cosmossdk.io/store/types"

"github.com/cosmos/ibc-go/modules/light-clients/08-wasm/internal/ibcwasm"
wasmtesting "github.com/cosmos/ibc-go/modules/light-clients/08-wasm/testing"
"github.com/cosmos/ibc-go/modules/light-clients/08-wasm/types"
clienttypes "github.com/cosmos/ibc-go/v8/modules/core/02-client/types"
Expand Down Expand Up @@ -65,6 +66,14 @@ func (suite *TypesTestSuite) TestStatus() {
},
exported.Unknown,
},
{
"client status is unauthorized: code hash is not stored",
func() {
err := ibcwasm.CodeHashes.Remove(suite.chainA.GetContext(), suite.codeHash)
suite.Require().NoError(err)
},
exported.Unauthorized,
},
}

for _, tc := range testCases {
Expand Down
Loading