-
Notifications
You must be signed in to change notification settings - Fork 956
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'bat/multistore-refactor' (#547)
* bat/multistore-refactor: changelog: add #547 wasm: update checksums [chore]: Lints and formatting [fix]: Fixed proof specs for non-existence proofs [fix]: Update the main tree when deleting a key [fix]: Fixed last ibc unit test [fix]: Fixed some tests. [feat]: Refactored the merkle tree into a more maintainable multi-store
- Loading branch information
Showing
14 changed files
with
628 additions
and
452 deletions.
There are no files selected for viewing
2 changes: 2 additions & 0 deletions
2
.changelog/unreleased/improvements/547-multistore-refactor.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
- Extend Merkle tree storage to support multiple Merkle trees with a uniform | ||
interface. ([#547](https://github.com/anoma/namada/pull/547)) |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
//! A module that contains | ||
|
||
use arse_merkle_tree::H256; | ||
use ics23::{HashOp, LeafOp, LengthOp, ProofSpec}; | ||
|
||
use super::traits::StorageHasher; | ||
|
||
/// Get the leaf spec for the base tree. The key is stored after hashing, | ||
/// but the stored value is the subtree's root without hashing. | ||
pub fn base_leaf_spec<H: StorageHasher>() -> LeafOp { | ||
LeafOp { | ||
hash: H::hash_op().into(), | ||
prehash_key: H::hash_op().into(), | ||
prehash_value: HashOp::NoHash.into(), | ||
length: LengthOp::NoPrefix.into(), | ||
prefix: H256::zero().as_slice().to_vec(), | ||
} | ||
} | ||
|
||
/// Get the leaf spec for the subtree. Non-hashed values are used for the | ||
/// verification with this spec because a subtree stores the key-value pairs | ||
/// after hashing. | ||
pub fn leaf_spec<H: StorageHasher>() -> LeafOp { | ||
LeafOp { | ||
hash: H::hash_op().into(), | ||
prehash_key: H::hash_op().into(), | ||
prehash_value: H::hash_op().into(), | ||
length: LengthOp::NoPrefix.into(), | ||
prefix: H256::zero().as_slice().to_vec(), | ||
} | ||
} | ||
|
||
/// Get the leaf spec for the ibc subtree. Non-hashed values are used for | ||
/// the verification with this spec because a subtree stores the | ||
/// key-value pairs after hashing. However, keys are also not hashed in | ||
/// the backing store. | ||
pub fn ibc_leaf_spec<H: StorageHasher>() -> LeafOp { | ||
LeafOp { | ||
hash: H::hash_op().into(), | ||
prehash_key: HashOp::NoHash.into(), | ||
prehash_value: HashOp::NoHash.into(), | ||
length: LengthOp::NoPrefix.into(), | ||
prefix: H256::zero().as_slice().to_vec(), | ||
} | ||
} | ||
|
||
/// Get the proof specs for ibc | ||
#[allow(dead_code)] | ||
pub fn ibc_proof_specs<H: StorageHasher>() -> Vec<ProofSpec> { | ||
let spec = arse_merkle_tree::proof_ics23::get_spec(H::hash_op()); | ||
let sub_tree_spec = ProofSpec { | ||
leaf_spec: Some(ibc_leaf_spec::<H>()), | ||
..spec.clone() | ||
}; | ||
let base_tree_spec = ProofSpec { | ||
leaf_spec: Some(base_leaf_spec::<H>()), | ||
..spec | ||
}; | ||
vec![sub_tree_spec, base_tree_spec] | ||
} | ||
|
||
/// Get the proof specs | ||
#[allow(dead_code)] | ||
pub fn proof_specs<H: StorageHasher>() -> Vec<ProofSpec> { | ||
let spec = arse_merkle_tree::proof_ics23::get_spec(H::hash_op()); | ||
let sub_tree_spec = ProofSpec { | ||
leaf_spec: Some(leaf_spec::<H>()), | ||
..spec.clone() | ||
}; | ||
let base_tree_spec = ProofSpec { | ||
leaf_spec: Some(base_leaf_spec::<H>()), | ||
..spec | ||
}; | ||
vec![sub_tree_spec, base_tree_spec] | ||
} |
Oops, something went wrong.