# Subtree Updater

The Subtree Updater is an offchain actor that saves the protocol gas by inserting batches of new notes into the [commitment tree](https://nocturne-xyz.gitbook.io/nocturne/protocol-details/commitment-tree) through "ZK Subtree Updates". The role is permissionless, so anyone can run a Subtree Updater.

You can read more about the subtree update mechanism [here](https://nocturne-xyz.gitbook.io/nocturne/commitment-tree#zk-subtree-update-insertions), but the TL;DR is that the subtree updater polls the contracts for new merkle tree insertions and keeps a local, up-to-date copy of the commitment tree in-memory. When enough insertions occur, the subtree updater will compute the new root using its local copy of the tree, publish it on-chain, and prove that it's correct using a zero-knowledge proof.
