State Updates & Deltas
State updates in a Merkle Patricia Trie are persistent and copy-on-write, ensuring that historical state can be preserved through "Path Shadowing".
"Imagine a giant LEGO castle. If you change one brick on a tower, you don't rebuild the whole castle—you only swap the affected section and its support structure."
Engineer's Note
When a leaf is updated, its hash changes. This invalidates the parent Branch node, which must also be re-hashed with the new child hash. This "ripple" continues up to the root, effectively creating a new version of the tree that shares unchanged nodes with the previous version.
Key Takeaways
Nodes are never updated in-place. Instead, new nodes are added to the database with new hashes.
Old versions of the trie remain accessible, which is vital for handling chain reorganizations (forks).
Only the O(log N) nodes along the modified path are updated, making state transitions highly efficient.