celestia-node icon indicating copy to clipboard operation
celestia-node copied to clipboard

IPLD/NMT improvements

Open Wondertan opened this issue 2 years ago • 11 comments

Right now, we store/exchange on the network redundant data that brings no benefits, and we should fix this together during BlockSync Overhaul:

  • [ ] Remove prepended one byte from each NMT IPLD node body(here and here)
    • It is possible to indirectly get the NMT Node type without serializing it. We can look at the number of links and the data size to determine its type(leaf or non-leaf). Look here for an example.
  • [ ] Remove additional NMT IPLD node per each leaf
    • Each nmtLeafNode links to an additional IPLD Node, while it should keep that body inside itself
    • This is needed to reduce one roundtrip for DASing operation and, in general, reduce the size of each block

Wondertan avatar Nov 09 '21 12:11 Wondertan

This sounds good, but I have some questions

It is possible to get NMT Node type indirectly, without serializing the type itself. WE can look at the amount of links.

would we have to know square size for that?

It is possible to get Namespace for each share encoded in inner non-leaf nodes of the NMT tree.

I think I'm missing something here. Mind elaborating on this a bit more? What if some non-leaf nodes, along with their respective leaf nodes, can't be found?

evan-forbes avatar Nov 10 '21 23:11 evan-forbes

Referencing this here as it is highly related: https://github.com/celestiaorg/celestia-node/pull/244#discussion_r761576295

liamsi avatar Dec 07 '21 14:12 liamsi

And this: https://github.com/celestiaorg/celestia-node/pull/244#discussion_r761422429

liamsi avatar Dec 07 '21 14:12 liamsi

@liamsi, I made a separate issue out of this. Even though they are related, your comments deserve a separate issue.

Wondertan avatar Dec 07 '21 15:12 Wondertan

https://github.com/celestiaorg/celestia-node/pull/464 relies on the fact that our NMT tree looks like:

---X
-X---X
X-X-X-X
X-X-X-X

While one of the points of this issue is to make the tree look like this:

---X
-X---X
X-X-X-X

So once we fix this issue, we should also fix https://github.com/celestiaorg/celestia-node/pull/464

Wondertan avatar Feb 22 '22 17:02 Wondertan

8 bytes additional Namespace for each share via NMT wrapper Can be avoided if we enable once

Why can't it be avoided today? Storage format is an implementation detail. So long as you can losslessly convert between formats, it doesn't matter what it's stored as.

adlerjohn avatar May 05 '22 13:05 adlerjohn

@adlerjohn you are right. It can be avoided today. See https://github.com/celestiaorg/nmt/issues/55#issuecomment-1118931841

liamsi avatar May 05 '22 18:05 liamsi

@adlerjohn, it can be avoided. My understanding was that we have to store everything we commit to via nmt.Push, but I missed that we can avoid storing some pieces of shares on the fly via Visitor in nmt and add them on the fly as well. However, as pointed out in the linked nmt issue, this is somewhat hacky, and, actually, a leaky abstraction that should be avoided ideally.

Wondertan avatar May 05 '22 22:05 Wondertan

Grooming 12/07/2022:

  • if we are fine with the current stack, we need to have this implemented before Incentivized Testnet

Bidon15 avatar Jul 12 '22 15:07 Bidon15

We need this before incentivized testnet.

Wondertan avatar Sep 15 '22 13:09 Wondertan

The description is now up to date

Wondertan avatar Sep 15 '22 13:09 Wondertan