-
Notifications
You must be signed in to change notification settings - Fork 624
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
fix(statemachine)!: use path within IBC store without escaping characters in solomachine #4429
fix(statemachine)!: use path within IBC store without escaping characters in solomachine #4429
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #4429 +/- ##
==========================================
- Coverage 79.50% 79.47% -0.04%
==========================================
Files 188 188
Lines 13038 13045 +7
==========================================
+ Hits 10366 10367 +1
- Misses 2241 2245 +4
- Partials 431 433 +2
|
@@ -81,6 +81,12 @@ func NewMerklePath(keyPath ...string) MerklePath { | |||
// This represents the path in the same way the tendermint KeyPath will | |||
// represent a key path. The backslashes partition the key path into | |||
// the respective stores they belong to. | |||
// | |||
// Deprecated: This function makes assumptions about the way a merkle path |
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 added a deprecated notice to these functions instead of removing them completely because I think removing them is API breaking and if I remove them in this PR the backport to v7.3.x will be more difficult. I will remove them in a follow up PR once this one gets merged.
@@ -28,7 +28,7 @@ type Prefix interface { | |||
// Path implements spec:CommitmentPath. | |||
// A path is the additional information provided to the verification function. | |||
type Path interface { | |||
String() string | |||
String() string // deprecated |
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.
If we remove this function, I am not sure if this interface makes much sense anymore...
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.
Agreed
@@ -516,11 +516,14 @@ func (solo *Solomachine) GenerateClientStateProof(clientState exported.ClientSta | |||
data, err := clienttypes.MarshalClientState(solo.cdc, clientState) | |||
require.NoError(solo.t, err) | |||
|
|||
merklePath := solo.GetClientStatePath(clientIDSolomachine) |
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.
These testing functions in this file return a merle path with 2 elements (first one for the IBC store), I could also change those to return only the second element. So something like this for GetClientStatePath
:
func (solo *Solomachine) GetClientStatePath(counterpartyClientIdentifier string) commitmenttypes.MerklePath {
return commitmenttypes.NewMerklePath(host.FullClientStatePath(counterpartyClientIdentifier))
}
Although the function the becomes a one-liner, so maybe we don't even to have a separate function to construct the path. Then in the test I would get key 0, instead of 1 as the path over which the solo machine signs the bytes.
Let me know what you think.
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 we should just call the 24-host paths directly in our code and remove these functions:
key := host.FullClientStatePath(counterpartyClientIdentififer)
I'm okay if you want to do it in a followup so as to avoid breaking changes in backport
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.
Yes, I will do that better in a follow-up PR, otherwise if I remove these functions now that's also API breaking.
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.
LGTM
@@ -28,7 +28,7 @@ type Prefix interface { | |||
// Path implements spec:CommitmentPath. | |||
// A path is the additional information provided to the verification function. | |||
type Path interface { | |||
String() string | |||
String() string // deprecated |
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.
Agreed
@@ -516,11 +516,14 @@ func (solo *Solomachine) GenerateClientStateProof(clientState exported.ClientSta | |||
data, err := clienttypes.MarshalClientState(solo.cdc, clientState) | |||
require.NoError(solo.t, err) | |||
|
|||
merklePath := solo.GetClientStatePath(clientIDSolomachine) |
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 we should just call the 24-host paths directly in our code and remove these functions:
key := host.FullClientStatePath(counterpartyClientIdentififer)
I'm okay if you want to do it in a followup so as to avoid breaking changes in backport
…olomachine-client
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.
Looks good to me! LGTM, left one question about the GetKey
method
} | ||
|
||
// in a multistore context: index 0 is the key for the IBC store in the multistore, index 1 is the key in the IBC store | ||
key, err := merklePath.GetKey(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.
GetKey
seems to do some unescaping on the string also, is this okay here?
from GetKey
:
key, err := url.PathUnescape(mp.KeyPath[i])
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 we should just use 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.
wouldn't this be fine considering escaping calls have been removed? It seems like it would just be best to tweak GetKey
.
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.
That's a good observation @damiannolan!
I think it is still fine, since it is doing unescaping. And also according to ICS 24 %
is not a valid character in identifiers and paths, so it should not happen that a path contains an escaped character and then GetKey
would return it unescaped.
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.
What do you guys prefer to do?
- Leave as is.
- Use
merklePath.KeyPath[1]
- Tweak
GetKey
. I would prefer to do this in a separate PR where I remove theString
andPretty
functions.
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.
Happy with opt 2 or 3 I think!
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.
if we're having a vote I'd go towards 3.
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.
Ok, I will go for 2 and implement 3 in the next PR. Nah, I changed my mind: I will go for 3, will make working on the follow-up PR easier.
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.
Done. I will merge when tests pass.
…ters in solomachine (backport #4429) (#4453) * fix(statemachine)!: use key within IBC store without escaping characters in solomachine (#4429) (cherry picked from commit 98b0c99) # Conflicts: # modules/light-clients/06-solomachine/client_state.go # modules/light-clients/07-tendermint/upgrade.go * fix conflicts * fix package usage * use sdkerrors * add changelog * Update CHANGELOG.md * Update CHANGELOG.md * Update CHANGELOG.md --------- Co-authored-by: Carlos Rodriguez <[email protected]>
…rklePath` (#4459) ## Description Second part of #4128. First part was #4429. closes: #4128 ### Commit Message / Changelog Entry ```bash fix(api)!: remove `Pretty` and `String` custom implementations of `MerklePath` ``` see the [guidelines](https://github.com/cosmos/ibc-go/blob/main/docs/dev/pull-requests.md#commit-messages) 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. - [x] Targeted PR against correct branch (see [CONTRIBUTING.md](https://github.com/cosmos/ibc-go/blob/main/docs/dev/pull-requests.md#pull-request-targeting)). - [x] Linked to Github issue with discussion and accepted design OR link to spec that describes this work. - [ ] Code follows the [module structure standards](https://github.com/cosmos/cosmos-sdk/blob/main/docs/docs/building-modules/11-structure.md) and [Go style guide](../docs/dev/go-style-guide.md). - [ ] Wrote unit and integration [tests](https://github.com/cosmos/ibc-go/blob/main/testing/README.md#ibc-testing-package). - [ ] Updated relevant documentation (`docs/`) or specification (`x/<module>/spec/`). - [ ] Added relevant `godoc` [comments](https://blog.golang.org/godoc-documenting-go-code). - [ ] Provide a [commit message](https://github.com/cosmos/ibc-go/blob/main/docs/dev/pull-requests.md#commit-messages) to be used for the changelog entry in the PR description for review. - [x] Re-reviewed `Files changed` in the Github PR explorer. - [ ] Review `Codecov Report` in the comment section below once CI passes.
Description
As discussed with @colin-axner, I implemented changes so that:
String
andPretty
functions become unused and can be removed later on. They make assumptions about formatting a merkle path in a multi store into a string that we shouldn't be making.ref: #4128
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.