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

Misleading comments about "counter" in NMT cacher #3070

Closed
rootulp opened this issue Jan 31, 2024 · 1 comment · Fixed by #3071
Closed

Misleading comments about "counter" in NMT cacher #3070

rootulp opened this issue Jan 31, 2024 · 1 comment · Fixed by #3071
Assignees
Labels
documentation Improvements or additions to documentation

Comments

@rootulp
Copy link
Collaborator

rootulp commented Jan 31, 2024

Context

// EDSSubTreeRootCacher caches the inner nodes for each row so that we can
// traverse it later to check for blob inclusion. NOTE: Currently this has to
// use a leaky abstraction (see docs on counter field below), and is not
// threadsafe, but with a future refactor, we could simply read from rsmt2d and
// not use the tree constructor which would fix both of these issues.
type EDSSubTreeRootCacher struct {
mut *sync.RWMutex
caches map[uint]*subTreeRootCacher
squareSize uint64
}

// Constructor fulfills the rsmt2d.TreeCreatorFn by keeping a pointer to the
// cache and embedding it as a nmt.NodeVisitor into a new wrapped nmt.
func (stc *EDSSubTreeRootCacher) Constructor(axis rsmt2d.Axis, axisIndex uint) rsmt2d.Tree {
// see docs of counter field for more
// info. if the counter is even or == 0, then we make the assumption that we
// are creating a tree for a row
var newTree wrapper.ErasuredNamespacedMerkleTree
switch axis {
case rsmt2d.Row:
strc := newSubTreeRootCacher()
stc.mut.Lock()
stc.caches[axisIndex] = strc
stc.mut.Unlock()
newTree = wrapper.NewErasuredNamespacedMerkleTree(stc.squareSize, axisIndex, nmt.NodeVisitor(strc.Visit))
default:
newTree = wrapper.NewErasuredNamespacedMerkleTree(stc.squareSize, axisIndex)
}
return &newTree
}

Problem

Both of the code blocks above refer to a counter field that doesn't exist 😕

Proposal

Investigate if the counter field was present in a previous implementation. If it has been removed, consider deleting these comments too.

@rootulp rootulp added the documentation Improvements or additions to documentation label Jan 31, 2024
@rootulp rootulp self-assigned this Jan 31, 2024
@rootulp
Copy link
Collaborator Author

rootulp commented Feb 3, 2024

Counter was introduced in #549 but it was removed in #926. The second PR didn't remove all the comments related to counter.

rootulp added a commit that referenced this issue Feb 6, 2024
Closes #3070

There are no instances of counter in `nmt_caching.go`. `paths.go` has a
counter field but that doesn't seem immediately relevant to where these
comments are so proposal to remove them.
0xchainlover pushed a commit to celestia-org/celestia-app that referenced this issue Aug 1, 2024
Closes celestiaorg/celestia-app#3070

There are no instances of counter in `nmt_caching.go`. `paths.go` has a
counter field but that doesn't seem immediately relevant to where these
comments are so proposal to remove them.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant