celestiaorg / rsmt2d

Go implementation of two dimensional Reed-Solomon merkle tree data availability scheme.
Apache License 2.0
162 stars 80 forks source link

`getTreeNameFromConstructorFn` does not work for registered trees #286

Closed rootulp closed 9 months ago

rootulp commented 9 months ago

Context

https://github.com/celestiaorg/rsmt2d/pull/277 introduced a breaking change that requires users of this library to register trees via RegisterTree. Trees are later fetched from a global map of trees based on their treeConstructor (a.k.a. treeCreatorFn).

Problem

This line does not evaluate to true when I expect it to. https://github.com/celestiaorg/rsmt2d/blob/bb5e119c2e8571fc8eb7aff3b6bca4915ffb4b18/tree.go#L77

For example, in https://github.com/celestiaorg/celestia-app/pull/3065 I'm registering a tree for the square size 1. Then I run TestMinDataAvailabilityHeader which fails because the pointer inside treeFn doesn't match the pointer inside treeConstructor.

Screenshot

Screenshot 2024-01-30 at 2 10 18 PM

Proposal

  1. Revert https://github.com/celestiaorg/rsmt2d/pull/277
  2. Explore https://github.com/celestiaorg/rsmt2d/pull/278