Skip to content

Commit

Permalink
Remove smt64 (0xPolygonMiden#1249)
Browse files Browse the repository at this point in the history
* Remove `smt64`

* remove unused imports

* Rename Sparse Merkle Tree title

* update changelog
  • Loading branch information
plafer authored and bobbinth committed Feb 26, 2024
1 parent 3e63ae3 commit b35a417
Show file tree
Hide file tree
Showing 8 changed files with 4 additions and 281 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
- Introduced `std::utils` module with `is_empty_word` procedure. Refactored `std::collections::smt`
and `std::collections::smt64` to use the procedure (#1107).
- Removed `checked` versions of the instructions in the `std::math::u64` module (#1142).
- Removed `std::collections::smt64` (#1249)

#### VM Internals
- Introduced the `Event` decorator and an associated `on_event` handler on the `Host` trait (#1119).
Expand Down
1 change: 0 additions & 1 deletion docs/src/tools/repl.md
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,6 @@ If the stdlib was added to the available libraries list `!use` command will prin
Modules available for importing:
std::collections::mmr
std::collections::smt
std::collections::smt64
...
std::mem
std::sys
Expand Down
14 changes: 1 addition & 13 deletions docs/src/user_docs/stdlib/collections.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,7 @@ The following procedures are available to read data from and make updates to a M
| pack | Computes a commitment to the given MMR and copies the MMR to the Advice Map using the commitment as a key.<br /><br />Inputs: `[mmr_ptr, ...]`<br />Outputs: `[HASH, ...]`<br /><br /> |
| unpack | Load the MMR peak data based on its hash.<br /><br />Inputs: `[HASH, mmr_ptr, ...]`<br />Outputs: `[...]`<br /><br />Where:<br />- `HASH`: is the MMR peak hash, the hash is expected to be padded to an even length and to have a minimum size of 16 elements.<br />- The advice map must contain a key with `HASH`, and its value is `num_leaves \|\| hash_data`, and hash_data is the data used to computed `HASH`<br />- `mmt_ptr`: the memory location where the MMR data will be written, starting with the MMR forest (the total count of its leaves) followed by its peaks. |

## Sparse Merkle Tree (64-bit key)

Module `std::collections::smt64` contains procedures for manipulating key-value maps with single-element keys and 4-element values. The current implementation is a thin wrapper over a simple Sparse Merkle Tree of depth 64. In the future, this will be replaced with a compact Sparse Merkle Tree implementation.

The following procedures are available to read data from and make updates to a Sparse Merkle Tree.

| Procedure | Description |
| ----------- | ------------- |
| get | Returns the value located under the specified key in the Sparse Merkle Tree defined by the specified root.<br /><br />If no values had been previously inserted under the specified key, an empty word is returned.<br /><br />Inputs: `[key, ROOT, ...]`<br />Outputs: `[VALUE, ROOT, ...]`<br /><br />Fails if the tree with the specified root does not exist in the VM's advice provider. |
| set | Inserts the specified value under the specified key in a Sparse Merkle Tree defined by the specified root. If the insert is successful, the old value located under the specified key is returned via the stack.<br /><br />If `VALUE` is an empty word, the new state of the tree is guaranteed to be equivalent to the state as if the updated value was never inserted.<br /><br />Inputs: `[VALUE, key, ROOT, ...]`<br />Outputs: `[OLD_VALUE, NEW_ROOT, ...]`<br /><br />Fails if the tree with the specified root does not exits in the VM's advice provider. |
| insert | Inserts the specified value under the specified key in a Sparse Merkle Tree defined by the specified root. If the insert is successful, the old value located under the specified key is returned via the stack.<br /><br />This procedure requires that `VALUE` be a non-empty word.<br /><br />Inputs: `[VALUE, key, ROOT, ...]`<br />Outputs: `[OLD_VALUE, NEW_ROOT, ...]`<br /><br />Fails if:<br />- The tree with the specified root does not exits in the VM's advice provider.<br />- The provided value is an empty word. |

## Sparse Merkle Tree (256-bit key)
## Sparse Merkle Tree

Module `std::collections::smt` contains procedures for manipulating key-value maps with 4-element keys and 4-element values. The underlying implementation is a Sparse Merkle Tree where leaves can exist only at depth 64. Initially, when a tree is empty, it is equivalent to an empty Sparse Merkle Tree of depth 64 (i.e., leaves at depth 64 are set and hash to [ZERO; 4]). When inserting non-empty values into the tree, the most significant element of the key is used to identify the corresponding leaf. All key-value pairs that map to a given leaf are inserted (ordered) in the leaf.

Expand Down
1 change: 0 additions & 1 deletion docs/src/user_docs/stdlib/main.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ Currently, Miden standard library contains just a few modules, which are listed
| Module | Description |
| ------ | ----------- |
| [std::collections::mmr](./collections.md#merkle-mountain-range) | Contains procedures for manipulating [Merkle Mountain Ranges](https://github.com/opentimestamps/opentimestamps-server/blob/master/doc/merkle-mountain-range.md). |
| [std::collections::smt64](./collections.md#sparse-merkle-tree-64) | Contains procedures for manipulating key-value maps with single-element keys and 4-element values. |
| [std::crypto::fri::frie2f4](./crypto/fri.md#fri-extension-2-fold-4) | Contains procedures for verifying FRI proofs (field extension = 2, folding factor = 4). |
| [std::crypto::hashes::blake3](./crypto/hashes.md#blake3) | Contains procedures for computing hashes using BLAKE3 hash function. |
| [std::crypto::hashes::sha256](./crypto/hashes.md#sha256) | Contains procedures for computing hashes using SHA256 hash function. |
Expand Down
74 changes: 0 additions & 74 deletions stdlib/asm/collections/smt64.masm

This file was deleted.

7 changes: 0 additions & 7 deletions stdlib/docs/collections/smt64.md

This file was deleted.

5 changes: 2 additions & 3 deletions stdlib/tests/collections/mod.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
use test_utils::{
crypto::{LeafIndex, MerkleStore, RpoDigest, SimpleSmt, Smt},
Felt, TestError, Word, EMPTY_WORD, ONE, ZERO,
crypto::{MerkleStore, RpoDigest, Smt},
Felt, Word, EMPTY_WORD,
};

mod mmr;
mod smt;
mod smt64;
182 changes: 0 additions & 182 deletions stdlib/tests/collections/smt64.rs

This file was deleted.

0 comments on commit b35a417

Please sign in to comment.