3

Where are the treestates stored?
In other words, when a JoinSplit transaction is being validated, where is the anchor being checked?
A look at https://github.com/zcash/zcash/blob/master/src/primitives/block.h brings me to conclude that the commitments (i.e., notes) merkle-tree is not stored in the block-header.
Is it in a LevelDB database?
What is the data-structure it uses for storing the mapping of trees roots for blocks?

Any answer with a specific reference to code will be very appreciated.

1 Answer 1

1

You are correct that the Sprout commitment tree root / anchor is not stored in the block header. It is calculated by each node when a block arrives, and is stored in the block index.

The Sapling commitment tree root is stored in the block header (in what was the hashReserved field); nodes check this against the block contents and reject blocks with an invalid root in the header. This will make shielded address support significantly easier to implement for light clients.

The mappings from Sprout and Sapling tree roots to the IncrementalMerkleTrees themselves are stored in the coins database, and can be accessed wherever you have a CCoinsView.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.