6

After reading the substrate documentation:

Child tries are useful when you want your own independent trie with a separate root hash that you can use to verify the specific content in that trie. Subsections of a trie do not have a root-hash-like representation that satisfy these needs automatically; thus a child trie is used instead.

It's still not very clear when would I want to choose a child trie to solve a given problem. It would be useful to know with more down to earth examples and use cases(e.g. from existing chains) when someone should consider using this API.

1 Answer 1

9

From my perspective, there are two major features of a child-trie which would make it a good choice over the standard storage options:

  1. You get a dedicated merkle root for the contents of just the child trie.
  2. You want to use an alternative trie format than the standard base-16 patricia merkle trie that Substrate uses. For example, a binary trie.

There are two main places that child tries are used in Substrate pallets today:

  1. Smart Contracts
  2. Parachain Crowdloans

In both of these cases, these applications take advantage of the dedicated merkle root to provide small and concise proofs of the data inside the trie.

For Parachain Crowdloans, you can use the merkle root of all the crowdloan contributions to easily upload potentially millions of user contributions via a single hash, and users can then provide proofs of their contributions against the merkle root.

For Contracts, the merkle root is used to be able to kill a contracts data (forming a tombstone), and at a later point re-instate the data if the contract were to become active again.

We have not really played with using alternative trie formats, but I believe that binary tries and other formats may provide major benefits to certain kinds of blockchain applications.

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.