-
Notifications
You must be signed in to change notification settings - Fork 72
Trie without extension node #11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 1 commit
Commits
Show all changes
126 commits
Select commit
Hold shift + click to select a range
776f324
fuse commit of no extension branch.
cheme 4eae594
Tabify.
cheme 5d79a12
Implementation for trie_root.
cheme fe603e8
Merge branch '12' into n_ext_trie_key, try to complete for no_ext, tests
cheme e7b299c
Fix test
cheme 2ca4542
Fuzz of prefix seems ok for pr 12, no_ext things are totally broken.
cheme cfeb96a
Fix iter_build key indexes.
cheme e38532c
Merge branch 'master' into n_ext_trie_key, tests are broken again
cheme 1d9be11
Fix merge regression
cheme f1fdcbd
No error found : need more tests (after evos).
cheme bd5b735
Put a no_ext header specific scheme (with second bit as in substrate).
cheme e727fbd
Fix decoding issue of iter
cheme b3c988c
Reset fuzzer to right no_ext impl, found a failing test (in comment).
cheme bdd99c0
Find and fix fuzzing error (a missing branch child ix).
cheme ac36fc9
Removing bench blobs.
cheme 42c2eba
Minor change (remove dead branch, and useless encoding, also panic on
cheme 84ff90d
Use a unique trait for spec (layout) : hasher, nodecodec and alogorithm
cheme e092a0c
Fuse triedbmut code, before remove NoExt variant
cheme 3bd3127
Fix merge and remove triedbmutnoext variant.
cheme a8b73f6
No instance for Layout (NodeCodec should have one at some point), to
cheme 1c34745
Apply layout trait to non mut trie too.
cheme 12842a6
Nibbleslice using inner trait to define multiple encoding: this is
cheme 4478ece
NibbleVec move size arelated methods.
cheme 318e7c8
Reverse padding in nibble
cheme b30698a
start testing, first broken part see triedbmut advance println
cheme 097fec5
Fix offset issue of nodecodec
cheme f892c76
Switch remaining tests to use postfix for no ext
cheme 57a86c5
Switch header encoding scheme. Failing test is related to the
cheme 0cab2eb
TrieStream implementation : warning it is not parameterized.
cheme f21398b
Back to prefix padded nibble (TODO see if removal of all previous change
cheme d36ba7d
Simplification of nibleslice, not stabilized yet (many unused and some
cheme bc1ae2b
fix stack of prefix on commit
cheme 4ddb1eb
fix into_part method
cheme da335d4
fix fuzz1
cheme f276ace
bad work on fixing fix: buf is needed only for terminal and recursive is
cheme c5d907d
small cleaning
cheme 71e8fab
Fix remove issue, will need more test (playpen on noext and check
cheme 0c7efd1
clean up prefixkeymut before merge with keyvec
cheme 8ee9798
implement, still 2 failing test (note on remove I did change prefix a…
cheme 241eb4a
nightly debug format
cheme 107027b
Use keyvec instead of keymut.
cheme ca950b9
ref padding constant
cheme ba7de31
remove PartialKey (same as NibbleSlice in this state).
cheme 5de3fbe
no ext error from playpen
cheme cf2b5e3
Fix playpen error.
cheme 2e8cd6a
fix some warnings
cheme 6c69177
use nibblevec instead of vec in iter, TODO still need remove a useless
cheme fbe84fb
end of switch Vec<u8> to NibbleVec, this will need a bench.
cheme 50fec85
make a nibble module to share field between vec and slice
cheme 275f5b8
push_pop on quarter
cheme 6fd7531
in progress - append_partial
cheme 959da6c
partial & prefix cannot be simply option but (nb_nibble, aligned_val)…
cheme dd93050
switch partial to (u8, u8)
cheme b756248
Replace prefix option by index bytes
cheme 9e45eda
clean code from padding_bitmask a bit
cheme 9657a15
Fix regression
cheme 3bfe451
fuzz1 and 2 passing
cheme 757f630
a few fix, next needed are combine_key and shifted_key
cheme 2704459
fix a few test
cheme d844cd2
fix range iter
cheme 8f428f1
remove a few todos and fix bench (except memdb).
cheme e88dbc2
cleaning
cheme 8a4f75e
Abstract buff size of iter_build
cheme 398c915
plug iter_build on TrieLayout
cheme 38c4899
Make children slice variable length depending on trait.
cheme 45009f8
Clone and debug for kf function
cheme 1c40a98
nibble vec append fix
cheme c4ace9a
right vec append fix
cheme 530f5f1
Add debug assertion to help implementation of codec.
cheme a8bcdf5
fix
cheme 28271c2
lookup advance branch for other than 16
cheme 57bb429
no_std update
cheme bce5c66
Fix no ext key lookup
cheme f9430e0
smaller empty prefix result
cheme 0ada0af
Fix wasm code (rust std doc for usize is unaccurate).
cheme 1a09044
bench len/size factor 2
cheme 7cec6af
Add test with values on encode_size, fix debug output (previous change
cheme b13bb9a
indent
cheme 06f5360
do not allow decoding of longer length node (encoding still truncate)
cheme ed68da6
format
cheme feb0660
Legacy prefix tools.
cheme 776a1f3
Fix legacy prefix
cheme 43b3225
Some documentation, and switch `masked_right` semantic to be similar to
cheme 727837d
Documentation improvement and breaking long lines.
cheme 8d1b2ae
some additional formatting
cheme a5a95bd
Remove BM from NodeCodec (specific to some implementation only).
cheme be66ce2
Invalid asumption about prefix ordering of key, fix doc and implement
cheme ddd24d2
OrderedPrefix instance.
cheme fec4a79
inprogress
cheme b45762d
No exessive buffer len, simplify flush_branch.
cheme 0218331
fix quarter error
cheme 82c920a
Merge branch 'master' into n_ext_trie
cheme a2f31c5
iter_build instance with print trace.
cheme 65b748a
gen impl over H.
cheme 56b1398
no_std
cheme 4c381d7
Merge branch 'n_ext_trie' of github.com:cheme/trie into n_ext_trie
cheme 2efca9b
fix no_std bis
cheme fcb70e2
no_std tierce
cheme 116978f
quick bench trie mut against trie root.
cheme af7f2bb
memory db building iter_build benches
cheme 6d38133
Merge branch 'master' into n_ext_trie
cheme 5eb9b99
update versioning
cheme 0a29389
Small doc changes and formatting fixes.
cheme 5e1126a
ChildBitmap renamed to more generic BitMap.
cheme c8e66cd
Renaming of LayOut to Layout.
cheme bb2588e
replace _ix with _index, bm with bitmap, and Ix with Index.
cheme 202bc74
Removing padding length from prefix.
cheme 0de2f85
Renamings.
cheme 93e9c13
Remove substrate from comment.
cheme 699cdc0
First pass of renamaings.
cheme 68e3832
Line length bellow 100.
cheme 19f92fb
add after comma space and after closure paramater space.
cheme 4f3bb58
Renaming of variables and methods.
cheme a65724d
Some line length.
cheme 502740b
Rename subtrait of TrieLayout to full names.
cheme b6e8f9c
Replace 'masked_' by 'pad_'.
cheme 5ada0fe
documentation small fixes.
cheme 2fe240c
Restore new line at end.
cheme 5a81906
Remove old feature.
cheme fb0e822
Merge branch 'master' into n_ext_trie
cheme 8a9cc47
Remove multiple trie radix support.
cheme d9a12d0
Comment.
cheme 869b4ce
formatting, and remove unused BitMap trait.
cheme 9b94482
Removing: radix related cache struct from iter_build.
cheme 5b9b022
No assumption on biggest_depth.
cheme 79d71b6
fixing biggest depth correctly.
cheme File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Legacy prefix tools.
- Loading branch information
commit feb0660b927991ec1944fd287a46f45bb0355a0c
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| // Copyright 2017, 2018 Parity Technologies | ||
| // Copyright 2017, 2019 Parity Technologies | ||
| // | ||
| // Licensed under the Apache License, Version 2.0 (the "License"); | ||
| // you may not use this file except in compliance with the License. | ||
|
|
@@ -365,7 +365,7 @@ where | |
| pub fn is_fat(&self) -> bool { self.spec == TrieSpec::Fat } | ||
| } | ||
|
|
||
| /// trait with definition of trie layout | ||
| /// Trait with definition of trie layout | ||
| pub trait TrieLayOut { | ||
|
||
| /// does the trie use extension before its branch | ||
| const USE_EXTENSION: bool; | ||
|
|
@@ -375,6 +375,67 @@ pub trait TrieLayOut { | |
| type CB: CacheBuilder<<Self::H as Hasher>::Out>; | ||
| } | ||
|
|
||
| /// Trait with operation on key value iterator. | ||
| /// This trait contains its own default implementation. | ||
| /// Implementing it allows to use alternate algorithm. | ||
| pub trait TrieOps: Sized + TrieLayOut { | ||
| /// Operation to build a trie db from its ordered iterator of key value | ||
| fn trie_build<DB, I, A, B>(db: &mut DB, input: I) -> <Self::H as Hasher>::Out where | ||
| DB: HashDB<Self::H, usize>, | ||
| I: IntoIterator<Item = (A, B)>, | ||
| A: AsRef<[u8]> + Ord, | ||
| B: AsRef<[u8]>, | ||
| { | ||
| let mut cb = TrieBuilder::new(db); | ||
| trie_visit::<Self, _, _, _, _>(input.into_iter(), &mut cb); | ||
| cb.root.unwrap_or(Default::default()) | ||
| } | ||
| /// Determine a trie root given its ordered contents, closed form. | ||
| fn trie_root<I, A, B>(input: I) -> <Self::H as Hasher>::Out where | ||
| I: IntoIterator<Item = (A, B)>, | ||
| A: AsRef<[u8]> + Ord, | ||
| B: AsRef<[u8]>, | ||
| { | ||
| let mut cb = TrieRoot::<Self::H, _>::default(); | ||
| trie_visit::<Self, _, _, _, _>(input.into_iter(), &mut cb); | ||
| cb.root.unwrap_or(Default::default()) | ||
| } | ||
|
|
||
| /// Determine a trie root node's data given its ordered contents, closed form. | ||
| fn trie_root_unhashed<I, A, B>(input: I) -> Vec<u8> where | ||
| I: IntoIterator<Item = (A, B)>, | ||
| A: AsRef<[u8]> + Ord, | ||
| B: AsRef<[u8]>, | ||
| { | ||
| let mut cb = TrieRootUnhashed::<Self::H>::default(); | ||
| trie_visit::<Self, _, _, _, _>(input.into_iter(), &mut cb); | ||
| cb.root.unwrap_or(Default::default()) | ||
| } | ||
|
|
||
| /// Encoding of index as a key (when reusing general trie for | ||
| /// indexed trie). | ||
| fn encode_index(input: u32) -> Vec<u8> { | ||
| // be for byte ordering | ||
| input.to_be_bytes().to_vec() | ||
| } | ||
| /// A trie root formed from the items, with keys attached according to their | ||
| /// compact-encoded index (using `parity-codec` crate). | ||
| fn ordered_trie_root<I, A>(input: I) -> <Self::H as Hasher>::Out | ||
| where | ||
| I: IntoIterator<Item = A>, | ||
| A: AsRef<[u8]>, | ||
| { | ||
| Self::trie_root(input | ||
| .into_iter() | ||
| .enumerate() | ||
| .map(|(i, v)| (Self::encode_index(i as u32), v)) | ||
| ) | ||
| } | ||
| /* /// Operation to build a trie from an unordered iterator of key value. | ||
| /// Operation to calculate a trie root from an ordered iterator of key value. | ||
| /// Operation to build a trie from an ordered iterator of key value.*/ | ||
| } | ||
|
|
||
| /// alias to acces hasher hash output type from a `TrieLayout` | ||
| pub type TrieHash<L> = <<L as TrieLayOut>::H as Hasher>::Out; | ||
| /// alias to acces bitmap codec from a `TrieLayout` | ||
|
|
||
This file contains hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"New" used here and further in this PR is not descriptive. If we move to a different scheme this naming will get out of hand. Better come up with proper name now.