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

fix(api)!: remove Pretty and String custom implementations of MerklePath #4459

Merged
merged 10 commits into from
Sep 26, 2023

Conversation

crodriguezvega
Copy link
Contributor

@crodriguezvega crodriguezvega commented Aug 24, 2023

Description

Second part of #4128. First part was #4429.

closes: #4128

Commit Message / Changelog Entry

fix(api)!: remove `Pretty` and `String` custom implementations of `MerklePath`

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.

  • Targeted PR against correct branch (see CONTRIBUTING.md).
  • Linked to Github issue with discussion and accepted design OR link to spec that describes this work.
  • Code follows the module structure standards and Go style guide.
  • Wrote unit and integration tests.
  • Updated relevant documentation (docs/) or specification (x/<module>/spec/).
  • Added relevant godoc comments.
  • Provide a commit message to be used for the changelog entry in the PR description for review.
  • Re-reviewed Files changed in the Github PR explorer.
  • Review Codecov Report in the comment section below once CI passes.

Copy link
Contributor Author

@crodriguezvega crodriguezvega left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The API breaking changes:

  • Removing String and Pretty.
  • Removing String from Path interface.

In which section of the migration docs should we mention them?

@@ -28,7 +28,6 @@ type Prefix interface {
// Path implements spec:CommitmentPath.
// A path is the additional information provided to the verification function.
type Path interface {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had to keep the interface because there was an import cycle between 02-client and 23-commitment, if I tried to use commitmenttypes.MerklePath as the type for path in the Verify(Non)Membership functions of the client state interface.

@@ -26,8 +26,6 @@ message MerklePrefix {
// arbitrary structured object (defined by a commitment type).
// MerklePath is represented from root-to-leaf
message MerklePath {
option (gogoproto.goproto_stringer) = false;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I removed this so that the proto compiler generated an implementation of String because that is needed when we do this.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the linked test should be updated to use a valid path for misbehaviour. A marshaled merkle path is not an expected singing path for solomachines

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It turns out that we might need to remove this because of this and this (why would we require the path to be proto-marshalled when submitting misbehaviour?).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Allowing it to be proto marshaled makes sense to me, but solo machine should not be proto marshaling the path when submitting misbeahviour, I think that might be a bug

Copy link
Contributor

@colin-axner colin-axner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! But we should not be referencing merkle path in solo machines anymore for testing. We should directly use the 24-host path

modules/light-clients/06-solomachine/client_state_test.go Outdated Show resolved Hide resolved
@@ -26,8 +26,6 @@ message MerklePrefix {
// arbitrary structured object (defined by a commitment type).
// MerklePath is represented from root-to-leaf
message MerklePath {
option (gogoproto.goproto_stringer) = false;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the linked test should be updated to use a valid path for misbehaviour. A marshaled merkle path is not an expected singing path for solomachines

Comment on lines +205 to 207
merklePath := commitmenttypes.NewMerklePath(host.FullClientStatePath("counterparty"))
path, err := solo.cdc.Marshal(&merklePath)
require.NoError(solo.t, err)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should be removing merkle path usage in solo machines

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

True! I will do that!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this going to be fixed in a followup?

Copy link
Contributor Author

@crodriguezvega crodriguezvega Sep 26, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I cannot change this one because we require at the moment the path to be a proto-marshalled MerklePath when submitting misbehaviour. I will open an issue for this.

@crodriguezvega
Copy link
Contributor Author

@colin-axner I implemented the feedback, but there's one thing I couldn't change and left a question in one of your comments

# Conflicts:
#	modules/core/23-commitment/types/commitment.pb.go
modules/core/23-commitment/types/merkle_test.go Outdated Show resolved Hide resolved
testing/solomachine.go Outdated Show resolved Hide resolved
crodriguezvega and others added 2 commits September 19, 2023 13:27
Co-authored-by: Damian Nolan <damiannolan@gmail.com>
Copy link
Contributor

@colin-axner colin-axner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, is there an issue for the misbehaviour unmarshaling fix?


require.Equal(t, "", zeroPath.String(), "zero element path does not have correct string representation")
require.Equal(t, "", zeroPath.Pretty(), "zero element path does not have correct pretty string representation")
require.Len(t, prefixedPath.GetKeyPath(), 2, "unexpected key path length")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should this test be asserting what each element is in the key path?

@@ -26,8 +26,6 @@ message MerklePrefix {
// arbitrary structured object (defined by a commitment type).
// MerklePath is represented from root-to-leaf
message MerklePath {
option (gogoproto.goproto_stringer) = false;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Allowing it to be proto marshaled makes sense to me, but solo machine should not be proto marshaling the path when submitting misbeahviour, I think that might be a bug

Comment on lines +205 to 207
merklePath := commitmenttypes.NewMerklePath(host.FullClientStatePath("counterparty"))
path, err := solo.cdc.Marshal(&merklePath)
require.NoError(solo.t, err)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this going to be fixed in a followup?

@mergify mergify bot merged commit 26e19db into main Sep 26, 2023
60 of 61 checks passed
@mergify mergify bot deleted the carlos/remove-string-functions-merklepath branch September 26, 2023 10:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

Wrong URL encoded path used in solomachine client.
3 participants