Compare commits

..

8 commits

Author SHA1 Message Date
8044e0c49c clarify as initial work 2024-08-22 18:14:44 -06:00
accda40e4b feat: implement root-checked Merkle tree insertion
This commit implements SparseMerkleTree::insert_ensure_root(), a version
of SparseMerkleTree::insert() that prevents modification of the tree if
the insert turns out to not result in the correct tree root (i.e., the
transaction is not valid).

This is an initial step towards issue 222.

As a logical next step, generalizing this to validation of inserting
multiple values at once will directly enable removing Merkle tree clones
in miden-node InnerState::apply_block().

For further work, as we generalize pre-validation for mutations we will
want a separate type to represent an arbitrary set of prospective
mutations on the Merkle tree and their validity, like the `ChangeSet`
type suggested in the issue.
2024-08-22 18:13:26 -06:00
38b09a57af give root-checked insertion commit a real commit message 2024-08-22 16:19:30 -06:00
b2e8ab66bd feat: implement root-checked Merkle tree insertion
This commit implements SparseMerkleTree::insert_ensure_root(), a version
of SparseMerkleTree::insert() that prevents modification of the tree if
the insert turns out to not result in the correct tree root (i.e., the
transaction is not valid).

This is a step towards issue 222, and an immediate step towards
0xPolygonMiden/miden-node issue 149.

Future work: as we generalize pre-validation for other mutations we will
likely want a separate type to represent prospective mutations on the
Merkle tree and their validity, (like the `ChangeSet` type suggested in
the issue).
2024-08-22 15:59:02 -06:00
20894b945c replace iter::once hack with an Option 2024-08-22 15:54:35 -06:00
00e2be79a4 feat: export Merkle get_value() in the trait 2024-08-22 15:54:24 -06:00
1795ef4ba3 WIP: smt: implement root-checked insertion 2024-08-22 15:54:24 -06:00
52ab7bca97 feat: impl hashing Merkle leaves that don't yet exist
This commit implements 'prospective leaf hashing' -- computing what the
hash of a sparse Merkle tree leaf *would* be for a key-value insertion
without actually performing that insertion.

For SimpleSmt, this is trivial, since the leaf hash and its payload are
the same.

For the full Smt, the new leaf payload (and thus, its hash) depend on
the existing payload in that leaf, making the prospective hash logic a
combination of the normal insertion logic and the normal hash logic. But
because we're only interested in the hash and not the intermediate
value, we can skip allocations and sorts for the payload itself.
2024-08-22 15:54:24 -06:00

2
series

@ -1 +1 @@
Subproject commit 4d1f33ab6775297ae617e353acbe8388e1c36fc8
Subproject commit accda40e4bd3a4bc6305eb9d7880e5ee5138f6d4