-
Notifications
You must be signed in to change notification settings - Fork 657
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
chore: adding initial localhost client testing #3085
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.
Looking good so far, I'll take a more in depth look at the test cases once the PR is marked ready for review!
merklePath, ok := path.(commitmenttypes.MerklePath) | ||
if !ok { | ||
return sdkerrors.Wrapf(clienttypes.ErrFailedChannelStateVerification, "todo: update error -- not found for path %s", path) | ||
} | ||
|
||
// todo: revisit this | ||
if len(merklePath.GetKeyPath()) != 2 && merklePath.KeyPath[0] != exported.StoreKey { | ||
return sdkerrors.Wrapf(clienttypes.ErrFailedChannelStateVerification, "todo: update error -- not found for path %s", path) | ||
} | ||
|
||
bz := store.Get([]byte(merklePath.KeyPath[1])) |
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.
could be a good candidate for an unexported function.
func readPathBytes(path exported.Path,) ([]byte, error) {...}
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 its more or less ok as is, given its a relatively small method compared to solomachine or tm
merklePath, ok := path.(commitmenttypes.MerklePath) | ||
if !ok { | ||
return sdkerrors.Wrapf(clienttypes.ErrFailedChannelStateVerification, "todo: update error -- not found for path %s", path) | ||
} | ||
|
||
// todo: revisit this | ||
if len(merklePath.GetKeyPath()) != 2 && merklePath.KeyPath[0] != exported.StoreKey { | ||
return sdkerrors.Wrapf(clienttypes.ErrFailedChannelStateVerification, "todo: update error -- not found for path %s", path) | ||
} | ||
|
||
bz := store.Get([]byte(merklePath.KeyPath[1])) |
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.
could use the function I suggested above here too
Created #3099 to address error returns in a follow-up PR. |
@@ -23,11 +24,6 @@ func NewClientState(chainID string, height clienttypes.Height) exported.ClientSt | |||
} | |||
} | |||
|
|||
// GetChainID returns the client state chain ID. | |||
func (cs ClientState) GetChainID() string { |
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.
seems unnecessary and unused
return sdkerrors.Wrapf(clienttypes.ErrFailedChannelStateVerification, "todo: update error -- not found for path %s", path) | ||
} | ||
|
||
bz := store.Get([]byte(merklePath.KeyPath[1])) |
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.
merklePath.KeyPath
is a []string
where the first element of the key path "/ibc/"
(the prefix that is applied here), but here we pass the core IBC store for verification, so we can trim the prefix or use keyPath[1]
(i.e. the key path without the prefix)
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 feel like we should include this reasoning in a comment alongside these checks.
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.
good call, done!
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.
Should we verify that the store is prefixed by KeyPath[0]? I don't know if there's an easy way to do that
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.
Really nice work with these tests, and nice job catching the ibc prefix issue! 👍
return sdkerrors.Wrapf(clienttypes.ErrFailedChannelStateVerification, "todo: update error -- not found for path %s", path) | ||
} | ||
|
||
bz := store.Get([]byte(merklePath.KeyPath[1])) |
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 feel like we should include this reasoning in a comment alongside these checks.
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.
ack changes 👍
@@ -153,8 +169,10 @@ func (cs ClientState) UpdateStateOnMisbehaviour(_ sdk.Context, _ codec.BinaryCod | |||
func (cs ClientState) UpdateState(ctx sdk.Context, cdc codec.BinaryCodec, clientStore sdk.KVStore, clientMsg exported.ClientMessage) []exported.Height { | |||
height := clienttypes.GetSelfHeight(ctx) | |||
|
|||
clientState := NewClientState(ctx.ChainID(), height) | |||
clientStore.Set([]byte(host.KeyClientState), clienttypes.MustMarshalClientState(cdc, clientState)) | |||
cs.ChainId = ctx.ChainID() |
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.
Maybe should be a separate PR. But do we need the chainID if the function got removed above
Description
closes: #XXXX
Commit Message / Changelog Entry
see the guidelines for commit messages. (view raw markdown for examples)
Before we can merge this PR, please make sure that all the following items have been
checked off. If any of the checklist items are not applicable, please leave them but
write a little note why.
docs/
) or specification (x/<module>/spec/
).godoc
comments.Files changed
in the Github PR explorer.Codecov Report
in the comment section below once CI passes.