-
Notifications
You must be signed in to change notification settings - Fork 625
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
Changes from 3 commits
8a59dbb
f946251
de738a8
7424f5c
6a74acb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 commentThe 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 commentThe reason will be displayed to describe this comment to others. Learn more. Agreed |
||
Empty() bool | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -128,15 +128,21 @@ func (cs *ClientState) VerifyMembership( | |
return errorsmod.Wrapf(ibcerrors.ErrInvalidType, "expected %T, got %T", commitmenttypes.MerklePath{}, path) | ||
} | ||
|
||
if merklePath.Empty() { | ||
return errorsmod.Wrap(commitmenttypes.ErrInvalidProof, "path is empty") | ||
if len(merklePath.GetKeyPath()) != 2 { | ||
return errorsmod.Wrapf(host.ErrInvalidPath, "path must be of length 2: %s", merklePath.GetKeyPath()) | ||
} | ||
|
||
// 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 commentThe reason will be displayed to describe this comment to others. Learn more.
from
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe we should just use There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What do you guys prefer to do?
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 commentThe 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 commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done. I will merge when tests pass. |
||
if err != nil { | ||
return errorsmod.Wrapf(host.ErrInvalidPath, "key not found at index 1: %v", err) | ||
} | ||
|
||
signBytes := &SignBytes{ | ||
Sequence: sequence, | ||
Timestamp: timestamp, | ||
Diversifier: cs.ConsensusState.Diversifier, | ||
Path: []byte(merklePath.String()), | ||
Path: key, | ||
Data: value, | ||
} | ||
|
||
|
@@ -178,11 +184,21 @@ func (cs *ClientState) VerifyNonMembership( | |
return errorsmod.Wrapf(ibcerrors.ErrInvalidType, "expected %T, got %T", commitmenttypes.MerklePath{}, path) | ||
} | ||
|
||
if len(merklePath.GetKeyPath()) != 2 { | ||
return errorsmod.Wrapf(host.ErrInvalidPath, "path must be of length 2: %s", merklePath.GetKeyPath()) | ||
} | ||
|
||
// 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) | ||
if err != nil { | ||
return errorsmod.Wrapf(host.ErrInvalidPath, "key not found at index 1: %v", err) | ||
} | ||
|
||
signBytes := &SignBytes{ | ||
Sequence: sequence, | ||
Timestamp: timestamp, | ||
Diversifier: cs.ConsensusState.Diversifier, | ||
Path: []byte(merklePath.String()), | ||
Path: key, | ||
Data: nil, | ||
} | ||
|
||
|
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.