Skip to content

Support different trie radix #84

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

Draft
wants to merge 29 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
0a22765
removing deprecated error description
cheme Mar 23, 2020
b8345c4
get operator back for multiple radix, change left_common implementation.
cheme Mar 23, 2020
43daba6
change type and trait, next need to adapt child index to the new handle
cheme Mar 23, 2020
76ee45f
Using function `at` instead of index.
cheme Mar 23, 2020
c8b260b
Complex buggy child slice index implementation
cheme Mar 24, 2020
189866d
easier implementation and certainly as fast.
cheme Mar 24, 2020
1479996
Switch to nibble ops at node level and add nibble ops trait to slice
cheme Mar 24, 2020
4261a29
remove nibble_ops from nibbleslice
cheme Mar 24, 2020
b9fe205
rem from nibblevec
cheme Mar 24, 2020
77d3a27
leftnibbleslice
cheme Mar 24, 2020
13c8c7f
quick rename before making child index generic
cheme Mar 24, 2020
8726e2e
Child index generics for iuse in trie codec, trie db mut and iter build.
cheme Mar 24, 2020
801ed93
iter_build.rs
cheme Mar 25, 2020
c58afde
associated array on triedbmut
cheme Mar 25, 2020
1809402
triedbmut
cheme Mar 25, 2020
a5a49fd
missed dbmut 16 (work previously as only tested for less)
cheme Mar 25, 2020
4c28f6b
trie_codec
cheme Mar 25, 2020
1a7a375
removing nibble_ops
cheme Mar 25, 2020
372b8f5
actual removal
cheme Mar 25, 2020
0bc5c85
bench & fuzzer
cheme Mar 25, 2020
8fd80a3
Bitmap code of reference trie
cheme Mar 25, 2020
bcdb36d
Tests for iter_build
cheme Mar 25, 2020
1ece330
restore the few test on nibbles.
cheme Mar 25, 2020
8059b33
Some renamings.
cheme Mar 25, 2020
e9e2562
not moving associated buf.
cheme Mar 25, 2020
d97931a
Merge branch 'master' into radix_new
cheme Apr 28, 2020
34d3192
check is leaking std in hashdb
cheme Apr 28, 2020
0a18226
Check pass on triedb if removing dev-deps, will probably need to change
cheme Apr 28, 2020
8706205
Ci without dev deps.
cheme Apr 28, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,4 @@ matrix:
script:
- cargo check --all --tests --benches
- cargo test --all
- cd trie-db && cargo check --no-default-features && cd ..
- cd memory-db && cargo check --no-default-features && cd ..
- cd trie-root && cargo check --no-default-features && cd ..
- cd check_no_std && cargo check --no-default-features && cd ..
3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@ members = [
"test-support/trie-standardmap",
"test-support/trie-bench",
"trie-db",
"trie-root"
"trie-root",
"check_no_std"
]
13 changes: 13 additions & 0 deletions check_no_std/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[package]
name = "check_no_std"
version = "0.0.1"
authors = ["Parity Technologies <[email protected]>"]
description = "Crate that import dependency as no std for runing cargo check"
repository = "https://github.com/paritytech/trie"
license = "Apache-2.0"
edition = "2018"

[dependencies]
trie-db = { path = "../trie-db", default-features = false, version = "0.20.1"}
memory-db = { path = "../memory-db", default-features = false, version = "0.20.1"}
trie-root = { path = "../trie-root", default-features = false, version = "0.16.0"}
24 changes: 24 additions & 0 deletions check_no_std/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// Copyright 2017, 2018 Parity Technologies
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

//! Crate to cargo check no std compatible library
//! without leaking dev-dependencies.
//! Do not publish.

#![no_std]


pub use trie_db::*;
pub use memory_db::*;
pub use trie_root::*;
7 changes: 4 additions & 3 deletions hash-db/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,14 @@ impl<T> MaybeDebug for T {}
/// nibbles (the node key can be split into prefix and node partial).
/// Therefore it is always the leftmost portion of the node key, so its internal representation
/// is a non expanded byte slice followed by a last padded byte representation.
/// The padded byte is an optional padded value.
pub type Prefix<'a> = (&'a[u8], Option<u8>);
/// The padded byte is a pair of u8 containing the number of nibble, followed by
/// the left aligned padded value.
pub type Prefix<'a> = (&'a[u8], (u8, u8));

/// An empty prefix constant.
/// Can be use when the prefix is not use internally
/// or for root nodes.
pub static EMPTY_PREFIX: Prefix<'static> = (&[], None);
pub static EMPTY_PREFIX: Prefix<'static> = (&[], (0, 0));

/// Trait describing an object that can hash a slice of bytes. Used to abstract
/// other types over the hashing algorithm. Defines a single `hash` method and an
Expand Down
14 changes: 7 additions & 7 deletions memory-db/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -217,8 +217,8 @@ impl<H: KeyHasher> KeyFunction<H> for PrefixedKey<H> {
pub fn prefixed_key<H: KeyHasher>(key: &H::Out, prefix: Prefix) -> Vec<u8> {
let mut prefixed_key = Vec::with_capacity(key.as_ref().len() + prefix.0.len() + 1);
prefixed_key.extend_from_slice(prefix.0);
if let Some(last) = prefix.1 {
prefixed_key.push(last);
if (prefix.1).0 > 0 {
prefixed_key.push((prefix.1).1);
}
prefixed_key.extend_from_slice(key.as_ref());
prefixed_key
Expand All @@ -243,16 +243,16 @@ impl<H: KeyHasher> KeyFunction<H> for LegacyPrefixedKey<H> {
/// Only for trie radix 16 trie.
pub fn legacy_prefixed_key<H: KeyHasher>(key: &H::Out, prefix: Prefix) -> Vec<u8> {
let mut prefixed_key = Vec::with_capacity(key.as_ref().len() + prefix.0.len() + 1);
if let Some(last) = prefix.1 {
if (prefix.1).0 == 0 {
prefixed_key.push(0);
prefixed_key.extend_from_slice(prefix.0);
} else {
let mut prev = 0x01u8;
for i in prefix.0.iter() {
prefixed_key.push((prev << 4) + (*i >> 4));
prev = *i;
}
prefixed_key.push((prev << 4) + (last >> 4));
} else {
prefixed_key.push(0);
prefixed_key.extend_from_slice(prefix.0);
prefixed_key.push((prev << 4) + ((prefix.1).1 >> 4));
}
prefixed_key.extend_from_slice(key.as_ref());
prefixed_key
Expand Down
Loading