celestiaorg / nmt

Namespaced Merkle Tree
Apache License 2.0
113 stars 39 forks source link

Check ordering of namespace among child nodes in HashNode function #129

Closed andrijamitrovic23 closed 1 year ago

andrijamitrovic23 commented 1 year ago

This testCase submits children nodes with invalid namespace ordering to HashNode function. The left child node has minNs larger than the maxNs of the same node, and in addition to that leftMinNs is even larger then the rightMinNs. The test will pass because HashNode function panics (in validateSiblingsNamespaceOrder) only if the rightMinNs is less than leftMaxNs.

Evan if the before mentioned test case is totally invalid based on the fact that the Push function will guarantee that the namespace ids will be ordered, it raises two questions or two paths for this issue:

  1. Should this test case be removed?
  2. Should validateSiblingsNamespaceOrder check the ordering of leftMinNs, leftMaxNs, rightMinNs and rightMaxNs among children nodes?

I would suggest that the 'validateSiblingsNamespaceOrder' checks the ordering of the children namespaces just to be more robust, but the decisions is on the development team.