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

feat: verifies namespace hash format to prevent panic in validateSiblingsNamespaceOrder #185

Merged
merged 34 commits into from
May 1, 2023

Conversation

staheri14
Copy link
Contributor

@staheri14 staheri14 commented Apr 27, 2023

Overview

Closes #138

Checklist

  • New and updated code has appropriate documentation
  • New and updated code has new and/or updated testing
  • Required CI checks are passing
  • Visual proof for any user facing features like CLI or documentation updates
  • Linked issues closed with keywords

@staheri14 staheri14 self-assigned this Apr 27, 2023
@staheri14 staheri14 added the enhancement New feature or request label Apr 27, 2023
@codecov
Copy link

codecov bot commented Apr 27, 2023

Codecov Report

Merging #185 (fb8ee89) into master (f403fd9) will increase coverage by 0.02%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##           master     #185      +/-   ##
==========================================
+ Coverage   95.66%   95.69%   +0.02%     
==========================================
  Files           5        5              
  Lines         554      557       +3     
==========================================
+ Hits          530      533       +3     
  Misses         14       14              
  Partials       10       10              
Impacted Files Coverage Δ
hasher.go 97.60% <100.00%> (+0.05%) ⬆️

@staheri14 staheri14 changed the title feat: ensures nodes comply by the namespace hash format in the validateSiblingsNamespaceOrder feat: verify namespace hash format to prevent panic in validateSiblingsNamespaceOrder Apr 28, 2023
@staheri14 staheri14 changed the title feat: verify namespace hash format to prevent panic in validateSiblingsNamespaceOrder feat: verifies namespace hash format to prevent panic in validateSiblingsNamespaceOrder Apr 28, 2023
@staheri14 staheri14 marked this pull request as ready for review May 1, 2023 15:31
rootulp
rootulp previously approved these changes May 1, 2023
// the minimum namespace ID of the right sibling. It returns ErrUnorderedSiblings error if the check fails. Note that the function assumes
// that the left and right nodes are in correct format, i.e., they are
// namespaced hash values. Otherwise, it panics.
// the minimum namespace ID of the right sibling. It returns ErrUnorderedSiblings error if the check fails.
Copy link
Collaborator

Choose a reason for hiding this comment

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

[unrelated] since a namespace now consists of a version and an ID, "namespace" may be clearer than "namespace ID". Thoughts on renaming usage of "namespace ID" to "namespace" in this repo so that the term matches its usage in celestia-app. If yes, I can create a new issue.

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 agree that the renaming is a good idea, as long as we're consistent with the terms we use. Regarding the namespace version, would it be something that the nmt lib needs to handle, or is it transparent and won't impact implementation? As far as I understand, the only change is the size of the namespace, and any further parsing of the namespace byte slice would depend on the specific logic of the application, correct?

Copy link
Collaborator

Choose a reason for hiding this comment

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

or is it transparent and won't impact implementation?

Won't impact implementation. The NMT lib is already used by celestia-app so no further changes are necessary to support namespaces with versions.

As far as I understand, the only change is the size of the namespace, and any further parsing of the namespace byte slice would depend on the specific logic of the application, correct?

Correct.

hasher.go Outdated Show resolved Hide resolved
hasher.go Outdated Show resolved Hide resolved
Copy link
Member

@evan-forbes evan-forbes left a comment

Choose a reason for hiding this comment

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

LGTM

@staheri14 staheri14 merged commit 1262b7f into master May 1, 2023
@staheri14 staheri14 deleted the resolves-panic-validateSiblings branch May 1, 2023 22:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

validateSiblingsNamespaceOrder can panic upon invalid inputs
3 participants