Skip to content

Instantly share code, notes, and snippets.

@phyro
Last active November 24, 2020 21:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save phyro/e0d698f2b8fbdb9bda79c67cead6ab22 to your computer and use it in GitHub Desktop.
Save phyro/e0d698f2b8fbdb9bda79c67cead6ab22 to your computer and use it in GitHub Desktop.
nimble node

Nimble node

New block handling

When we receive a new block we:

  1. validate the rangeproofs, update the rangeproof PMMR and discard the rangeproofs if they are valid - storing an output info becomes 32 bytes instead of 700 bytes
  2. forget about the block that is "older than 2 weeks"

Note: We don't really need the kernel signatures once we have validated them so perhaps we can drop this as well to further reduce the size?

Kernels

Let's define a curve point kernel_accumulator that starts with a value of 0*G. When we receive a valid block, we pop the block that is now more than 2 weeks old and add all the kernel commitment points it that were present in that block to the kernel_accumulator point. To validate the chain we can "pretend" we have a signature for the kernel_accumulator curve point. We can do that because we have validated all the signatures that collectively add to that point which means we don't make any new assumptions doing so.

Kernel MMR => PMMR

Since MMR is an append only structure, we know that kernels have an order from oldest to newest. We only need to keep the leaves of the kernels younger than 2 weeks. This means that we can prune most of the kernel MMR - I think we only need to keep the peaks of the merkle trees and all the paths from the current leaves to the root.

Output PMMR

This one is already getting prunned when the outputs are spent. Is it possible to improve on this somehow?

RangeProof PMMR

Since we forget rangeproofs right away, we can prune these as well and only keep the peaks of the merkle trees we have. This means this structure that was the most costly now (I think) becomes the cheapest because we only need a few hashes (the information needed for future validation).

Header PMMR

I think the situation here is similar as with kernels pmmr. Since this is append only, we can keep only the last 2 weeks of header data and the peaks.

UTXO Bitmap MMR

Not sure about this one

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment