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: simplified BuildMerklePath #7863

Merged
merged 4 commits into from
Jan 23, 2025

Conversation

srdtrk
Copy link
Member

@srdtrk srdtrk commented Jan 21, 2025

Description

closes: #7642


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 the 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/).
  • Added relevant godoc comments.
  • Provide a conventional commit message to follow the repository standards.
  • Include a descriptive changelog entry when appropriate. This may be left to the discretion of the PR reviewers. (e.g. chores should be omitted from changelog)
  • Re-reviewed Files changed in the GitHub PR explorer.
  • Review SonarCloud Report in the comment section below once CI passes.

@srdtrk srdtrk linked an issue Jan 21, 2025 that may be closed by this pull request
func BuildMerklePath(prefix [][]byte, path []byte) commitmenttypesv2.MerklePath {
prefixLength := len(prefix)
if prefixLength == 0 {
panic("cannot build merkle path with empty prefix")
Copy link
Member

Choose a reason for hiding this comment

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

Don't think this should necessarily error. If there's no prefix, the path should just be returned as it was originally. See removed diff

This would be equivalent to a chain storing the ICS24 paths directly under root. Which is potentially possible for a solomachine chain or something equivalent

Copy link
Member

Choose a reason for hiding this comment

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

What is the reasoning for changing the behavior here?

Copy link
Member

Choose a reason for hiding this comment

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

Ahh i see it was decided in the original issue! Ok, i mean i suppose we could require all implementations to store under a prefix

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't remember the entire context for why we said this, but it was something we mentioned during the alpha audit itself, I believe.

Copy link
Member Author

Choose a reason for hiding this comment

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

I could take this back. I don't feel strongly about it. What should we do?

Copy link
Contributor

Choose a reason for hiding this comment

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

@AdityaSripal can have the final say on it :)

Copy link
Member

Choose a reason for hiding this comment

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

I think its more likely that someone accidentally leaves prefix empty than having a counterparty that is genuinely storing everything under root.

So lets have the error for now, and if we ever have a user run into this issue and report it we can change the behavior of this function quite easily


lastElement := prefixKeys[len(prefixKeys)-1]
// copy prefix to avoid modifying the original slice
prefix = append([][]byte(nil), prefix...)
Copy link
Member

Choose a reason for hiding this comment

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

Should we name this var to something else since it eventually becomes the full path?

Copy link
Contributor

Choose a reason for hiding this comment

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

Agreed.
Also good to not reassign or change function arguments, so would prefer a new name in any case.

Copy link
Member Author

Choose a reason for hiding this comment

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

done

@gjermundgaraba gjermundgaraba added the priority PRs that need prompt reviews label Jan 22, 2025
Copy link

@gjermundgaraba gjermundgaraba merged commit 379e3d2 into feat/ibc-eureka Jan 23, 2025
66 checks passed
@gjermundgaraba gjermundgaraba deleted the serdar/7642-fix-build-mp branch January 23, 2025 10:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority PRs that need prompt reviews
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Clean up and fix BuildMerklePath
3 participants