Skip to content

Commit

Permalink
Update MPT for aiken==v1.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
KtorZ committed Sep 6, 2024
1 parent 463b9e3 commit 8d8c703
Show file tree
Hide file tree
Showing 8 changed files with 227 additions and 269 deletions.
24 changes: 24 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,29 @@
# Changelog

## v2.0.0 - 2024-09-06

### Added

N/A

### Changed

#### on-chain

- Requires `aiken >= 1.1.0`.

- Requires `aiken-lang/stdlib >= 2.0.0` && `aiken-lang/stdlib < 3.0.0`.

- Creating an empty trie is no longer a function `empty()` but a constant `empty`.

#### off-chain

N/A

### Removed

N/A

## v1.1.0 - 2024-07-23

### Added
Expand Down
20 changes: 10 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,16 +53,16 @@ This library implements a few optimizations. We borrow ideas from the [Ethereum'

While this optimization sacrifices some memory and CPU execution units for smaller proof sizes, the library ultimately achieves a good trade-off. The table below summarizes the proof size, memory units, and CPU units for various sizes of tries. Note that the numbers in the table correspond to _one proof verification_ (e.g., membership). Insertion and deletion in the trie both require _two proof verifications_, so double the numbers!

trie size | avg proof size (bytes) | avg proof mem units | avg proof cpu units |
---: | -------------: | ------------: | ------------: |
10² | 250 | 70K | 28M |
10³ | 350 | 100K | 42M |
10⁴ | 460 | 130K | 56M |
10⁵ | 560 | 160K | 70M |
10⁶ | 670 | 190K | 84M |
10⁷ | 780 | 220K | 98M |
10⁸ | 880 | 250K | 112M |
10⁹ | 990 | 280K | 126M |
trie size | avg proof size (bytes) | avg proof mem units | avg proof cpu units |
---: | -------------: | ------------: | ------------: |
10² | 250 | 70K <sup>(0.70%)</sup> | 18M <sup>(0.12%)</sup> |
10³ | 350 | 100K <sup>(1.00%)</sup> | 26M <sup>(0.19%)</sup> |
10⁴ | 460 | 130K <sup>(1.30%)</sup> | 35M <sup>(0.25%)</sup> |
10⁵ | 560 | 160K <sup>(1.60%)</sup> | 44M <sup>(0.31%)</sup> |
10⁶ | 670 | 190K <sup>(1.90%)</sup> | 53M <sup>(0.38%)</sup> |
10⁷ | 780 | 220K <sup>(2.20%)</sup> | 62M <sup>(0.44%)</sup> |
10⁸ | 880 | 250K <sup>(2.50%)</sup> | 71M <sup>(0.51%)</sup> |
10⁹ | 990 | 280K <sup>(2.80%)</sup> | 79M <sup>(0.56%)</sup> |

> [!NOTE]
>
Expand Down
4 changes: 2 additions & 2 deletions on-chain/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ This package provides an Aiken library for working with an authenticated key/val
## Installation

```
aiken add --version 1.1.0 aiken-lang/merkle-patricia-forestry
aiken add aiken-lang/merkle-patricia-forestry --version 2.0.0
```

## Documentation
Expand All @@ -16,7 +16,7 @@ The documentation is generated from `aiken docs` and [available here](https://ai

A non-trivial example of a [fruit map](https://github.com/aiken-lang/merkle-patricia-forestry/blob/main/on-chain/lib/aiken/merkle-patricia-forestry.tests.ak#L90) is available in the source. It illustrate how to use the various `from_root`, `has`, `insert` and `delete` primitives.

```ak
```aiken
test insert_bitcoin_block_845602() {
let trie =
mpf.from_root(
Expand Down
11 changes: 6 additions & 5 deletions on-chain/aiken.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,26 @@

[[requirements]]
name = "aiken-lang/stdlib"
version = "2.0.0"
version = "v2"
source = "github"

[[requirements]]
name = "aiken-lang/fuzz"
version = "main"
version = "v2"
source = "github"

[[packages]]
name = "aiken-lang/stdlib"
version = "2.0.0"
version = "v2"
requirements = []
source = "github"

[[packages]]
name = "aiken-lang/fuzz"
version = "main"
version = "v2"
requirements = []
source = "github"

[etags]
"aiken-lang/fuzz@main" = [{ secs_since_epoch = 1725585344, nanos_since_epoch = 985841000 }, "34ffec10cce786bf823c7505589a3b5e0663792ef8efd31f870d7bcc37e0f593"]
"aiken-lang/fuzz@v2" = [{ secs_since_epoch = 1725614006, nanos_since_epoch = 531726000 }, "34ffec10cce786bf823c7505589a3b5e0663792ef8efd31f870d7bcc37e0f593"]
"aiken-lang/stdlib@v2" = [{ secs_since_epoch = 1725614006, nanos_since_epoch = 100184000 }, "d79382d2b6ecb3aee9b0755c31d8a5bbafe88a7b3706d7fb8a52fd4d05818501"]
4 changes: 2 additions & 2 deletions on-chain/aiken.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ platform = "github"

[[dependencies]]
name = "aiken-lang/stdlib"
version = "2.0.0"
version = "v2"
source = "github"

[[dependencies]]
name = "aiken-lang/fuzz"
version = "main"
version = "v2"
source = "github"
5 changes: 2 additions & 3 deletions on-chain/lib/aiken/merkle-patricia-forestry.ak
Original file line number Diff line number Diff line change
Expand Up @@ -78,13 +78,12 @@ pub fn from_root(root: ByteArray) -> MerklePatriciaForestry {
MerklePatriciaForestry { root }
}

/// since | <code>1.0.0</code>
/// since | <code>2.0.0</code>
/// --- | ---
///
/// Construct a new empty [MerklePatriciaForestry](#MerklePatriciaForestry).
pub fn empty() -> MerklePatriciaForestry {
pub const empty: MerklePatriciaForestry =
MerklePatriciaForestry { root: null_hash }
}

// ## Querying

Expand Down
Loading

0 comments on commit 8d8c703

Please sign in to comment.