Skip to content

Commit

Permalink
Merge pull request #3 from keep-starknet-strange/wasm_compatibility
Browse files Browse the repository at this point in the history
Promis c'est la dernière
  • Loading branch information
damip authored Jan 11, 2024
2 parents 03103a0 + 6a1aa00 commit 5f1096b
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,4 @@ jobs:
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ./lcov.info
fail_ci_if_error: true
fail_ci_if_error: true
16 changes: 14 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# bonsai-trie

![example workflow](https://github.com/massalabs/bonsai-trie/actions/workflows/check_lint.yml/badge.svg) ![example workflow](https://github.com/massalabs/bonsai-trie/actions/workflows/test.yml/badge.svg) [![codecov](https://codecov.io/gh/massalabs/bonsai-trie/graph/badge.svg?token=598URC32TV)](https://codecov.io/gh/massalabs/bonsai-trie)

![example workflow](https://github.com/keep-starknet-strange/bonsai-trie/actions/workflows/check_lint.yml/badge.svg) ![example workflow](https://github.com/keep-starknet-strange/bonsai-trie/actions/workflows/test.yml/badge.svg) [![codecov](https://codecov.io/gh/keep-starknet-strange/bonsai-trie/branch/oss/graph/badge.svg?token=kfNJzdTYyf)](https://codecov.io/gh/keep-starknet-strange/bonsai-trie)

This crate provides a storage implementation based on the Bonsai Storage implemented by [Besu](https://hackmd.io/@kt2am/BktBblIL3).
It is a key/value storage that uses a Madara Merkle Trie to store the data.
Expand Down Expand Up @@ -37,6 +36,7 @@ use bonsai_trie::{
BonsaiStorageError,
id::{BasicIdBuilder, BasicId},
BonsaiStorage, BonsaiStorageConfig, BonsaiTrieHash,
ProofNode, Membership
};
use starknet_types_core::felt::Felt;
use starknet_types_core::hash::Pedersen;
Expand Down Expand Up @@ -133,6 +133,18 @@ fn main() {
.insert(&BitVec::from_vec(pair4.0.clone()), &pair4.1)
.unwrap();
bonsai_storage.commit(id_builder.new_id()).unwrap();
let proof = bonsai_storage
.get_proof(&BitVec::from_vec(pair3.0.clone()))
.unwrap();
assert_eq!(
BonsaiStorage::<BasicId, RocksDB<BasicId>>::verify_proof(
bonsai_storage.root_hash().unwrap(),
&BitVec::from_vec(pair3.0.clone()),
pair3.1,
&proof
),
Some(Membership::Member)
);
}
```

Expand Down
3 changes: 2 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@
#![cfg_attr(not(feature = "std"), no_std)]
extern crate alloc;

use crate::trie::merkle_tree::{Membership, MerkleTree, ProofNode};
use crate::trie::merkle_tree::MerkleTree;
use alloc::{format, vec::Vec};
use bitvec::{order::Msb0, slice::BitSlice};
use bonsai_database::{BonsaiPersistentDatabase, KeyType};
Expand All @@ -109,6 +109,7 @@ pub mod id;

pub use bonsai_database::BonsaiDatabase;
pub use error::BonsaiStorageError;
pub use trie::merkle_tree::{Membership, ProofNode};

#[cfg(test)]
mod tests;
Expand Down
1 change: 1 addition & 0 deletions src/tests/mod.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
mod madara_comparison;
mod proof;
mod simple;
mod transactional_state;
mod trie_log;

0 comments on commit 5f1096b

Please sign in to comment.