Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
74 commits
Select commit Hold shift + click to select a range
af6a8fd
init from other pr, have some code up to client (not client db),
cheme Sep 23, 2019
4db0a7f
Dumb state_db implementation, mostly boiler plate, but cannot work as
cheme Sep 24, 2019
19df6e9
TODO2 variant for in memory
cheme Sep 25, 2019
3989fea
traits in place, still need to parameterized with blocknb &| branchix
cheme Sep 25, 2019
6a6606d
passing block hash as state in a convoluted way
cheme Sep 25, 2019
934c800
passing block hash as state in a convoluted way
cheme Sep 25, 2019
5d3d47e
Recover previous branch index code without persistence.
cheme Sep 25, 2019
aeab064
let's remove branch range set of changed and removed in next commit
cheme Sep 26, 2019
57e862e
removed delta in branch (not needed if no persistence)
cheme Sep 26, 2019
4edbf27
Before using range instead of hash (we move range to upper client on
cheme Sep 26, 2019
91b87d7
use also block number for query (when not in statedb we need number).
cheme Sep 26, 2019
966a09f
Fixing finalize state algo.
cheme Sep 27, 2019
a37a32f
remove keys from commit set, this likely indicates broken code, will
cheme Sep 27, 2019
4714b70
put a client test, for rest of test reset_storage and genesis build
cheme Sep 27, 2019
5e90b20
Get needed component from branch history-data
cheme Oct 1, 2019
f6956b1
use history from utils
cheme Oct 1, 2019
9ba8057
Test issue is that query on remove hash do not work
cheme Oct 1, 2019
31c1ee3
test commit set
cheme Oct 2, 2019
6209f4d
fix unpin gc
cheme Oct 2, 2019
70f69b6
missing offstate prunnig handling
cheme Oct 2, 2019
6803c86
previous pruning did not make sense, switch to only storing touched key
cheme Oct 2, 2019
2497575
Figure out pruning (see prune_one/prune_two tests).
cheme Oct 3, 2019
e86fdd2
end fixing pruning test, remainings root lib tests to adjust
cheme Oct 3, 2019
e48cf43
fix gc call block index.
cheme Oct 4, 2019
0e3c65e
state_db tests passing.
cheme Oct 4, 2019
13ea088
fix underflow
cheme Oct 4, 2019
92c699c
before switching to absolute indexing (option<u64> to u64).
cheme Oct 4, 2019
bf79879
complete first test in client db, new todo.
cheme Oct 4, 2019
3913ba7
Merge branch 'master' into chain-aux-merge
cheme Oct 4, 2019
4dc2c8d
serialized with default
cheme Oct 7, 2019
03080c4
serialized with default is useless
cheme Oct 7, 2019
8eb5e07
few warning fix
cheme Oct 7, 2019
c89274d
simplify state machine offstate traits, TODO2 will be simple hashmap
cheme Oct 7, 2019
249770b
further simplify
cheme Oct 7, 2019
69fef43
Remove stub state machine implementation.
cheme Oct 7, 2019
a547560
init offstate for tests, but tests will only be interesting with chil…
cheme Oct 7, 2019
397d510
rem todos
cheme Oct 7, 2019
c133a0b
compact casts
cheme Oct 7, 2019
f197d7d
compact casts
cheme Oct 7, 2019
9846613
quick prune test
cheme Oct 7, 2019
d51e98f
break some lines
cheme Oct 7, 2019
fff7cb5
fix
cheme Oct 7, 2019
d55211a
split commit set to have offstate pruning only when needed.
cheme Oct 8, 2019
27ca685
Fix logic of pruning in client (prior it did not take account of last
cheme Oct 8, 2019
64b4102
No need for special revert unless we create archive mode with pruning
cheme Oct 8, 2019
5072f85
Do not keep deletion in branch storage.
cheme Oct 8, 2019
8f8ecc9
sed renaming of offstate to more generic and less incorect 'kv' (as key
cheme Oct 8, 2019
35bc11e
switch overlay transaction to the inner hashmap storage, only change to
cheme Oct 8, 2019
d111288
Remove commit kv from revert.
cheme Oct 9, 2019
dd9dddb
test db better handling
cheme Oct 9, 2019
df950a5
cleaning pass.
cheme Oct 9, 2019
0ca6530
starting using keyspace, storing in the overlay next to the child trie
cheme Oct 9, 2019
0dd36d0
it is tricky, but clearly getting rid of keyspace in overlayed change
cheme Oct 9, 2019
34cf138
wrong approach (the overlay db code for kv is not strictly needed),
cheme Oct 9, 2019
a732231
a todo
cheme Oct 10, 2019
ae180ed
Slight change to 'into_committed' proto, to allow resolving
cheme Oct 10, 2019
c39385b
Merge branch 'chain-aux2' into kv-keyspace
cheme Oct 10, 2019
d53dbba
boilerplate changes.
cheme Oct 10, 2019
9a3d762
Change trie crate from child_trie_soft_min
cheme Oct 10, 2019
da23a0c
prepare change
cheme Oct 10, 2019
3931280
fix proof test
cheme Oct 10, 2019
f6268ab
need a kv_storage function in backend.
cheme Oct 11, 2019
431f93d
add 'kv_store' to state machine backend
cheme Oct 11, 2019
9ccf87f
Merge branch 'chain-aux2' into kv-keyspace
cheme Oct 11, 2019
2b4dad9
state machine missing functions.
cheme Oct 11, 2019
fc16bae
fix other modules compilation.
cheme Oct 11, 2019
ec10b6d
revert into_committed and TODO for caching that is major (child root
cheme Oct 11, 2019
1209ac7
apply renaming
cheme Oct 11, 2019
0eed411
Get and modify previous transaction test.
cheme Oct 11, 2019
42bbd9d
revert into_committed to previous implementation
cheme Oct 11, 2019
b06ec1b
Merge branch 'chain-aux2' into kv-keyspace
cheme Oct 11, 2019
b0dce4a
Merge branch 'master' into chain-aux2
cheme Oct 11, 2019
03e47c2
Merge branch 'chain-aux2' into kv-keyspace
cheme Oct 11, 2019
899e151
Add a place holder for child trie deletion in journals.
cheme Oct 16, 2019
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
Prev Previous commit
Next Next commit
boilerplate changes.
  • Loading branch information
cheme committed Oct 10, 2019
commit d53dbba034e2faa9400e1c08b3dcadf6bde7d29d
5 changes: 5 additions & 0 deletions core/client/db/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ use trie::{MemoryDB, PrefixedMemoryDB, prefixed_key};
use parking_lot::{Mutex, RwLock};
use primitives::{H256, Blake2Hasher, ChangesTrieConfiguration, convert_hash, traits::CodeExecutor};
use primitives::storage::well_known_keys;
use primitives::child_trie::KeySpace;
use sr_primitives::{
generic::{BlockId, DigestItem}, Justification, StorageOverlay, ChildrenStorageOverlay,
BuildStorage,
Expand Down Expand Up @@ -149,6 +150,10 @@ impl<B: BlockT> StateBackend<Blake2Hasher> for RefTrackingState<B> {
self.state.child_storage(storage_key, key)
}

fn get_child_keyspace(&self, storage_key: &[u8]) -> Result<Option<KeySpace>, Self::Error> {
self.state.get_child_keyspace(storage_key)
}

fn exists_storage(&self, key: &[u8]) -> Result<bool, Self::Error> {
self.state.exists_storage(key)
}
Expand Down
5 changes: 5 additions & 0 deletions core/client/db/src/storage_cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ use parking_lot::{Mutex, RwLock, RwLockUpgradableReadGuard};
use linked_hash_map::{LinkedHashMap, Entry};
use hash_db::Hasher;
use sr_primitives::traits::{Block as BlockT, Header};
use primitives::child_trie::KeySpace;
use state_machine::{backend::Backend as StateBackend, TrieBackend};
use log::trace;
use super::{StorageCollection, ChildStorageCollection};
Expand Down Expand Up @@ -531,6 +532,10 @@ impl<H: Hasher, S: StateBackend<H>, B: BlockT> StateBackend<H> for CachingState<
Ok(value)
}

fn get_child_keyspace(&self, storage_key: &[u8]) -> Result<Option<KeySpace>, Self::Error> {
self.state.get_child_keyspace(storage_key)
}

fn exists_storage(&self, key: &[u8]) -> Result<bool, Self::Error> {
Ok(self.storage(key)?.is_some())
}
Expand Down
2 changes: 1 addition & 1 deletion core/client/src/cht.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ pub fn build_proof<Header, Hasher, BlocksI, HashesI>(
{
let transaction = build_pairs::<Header, _>(cht_size, cht_num, hashes)?
.into_iter()
.map(|(k, v)| (None, None, k, Some(v)))
.map(|(k, v)| (None, k, Some(v)))
.collect::<Vec<_>>();
let mut storage = InMemoryState::<Hasher>::default().update(InMemoryTransaction {
storage: transaction,
Expand Down
9 changes: 6 additions & 3 deletions core/client/src/genesis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,8 @@ mod tests {
).genesis_map();
let genesis_hash = insert_genesis_block(&mut storage);

let backend = InMemory::from(storage);
// TODO EMCH need to put kv in genesis
let backend = InMemory::from((storage.0, storage.1, Default::default()));
let (b1data, _b1hash) = block1(genesis_hash, &backend);

let mut overlay = OverlayedChanges::default();
Expand Down Expand Up @@ -192,7 +193,8 @@ mod tests {
).genesis_map();
let genesis_hash = insert_genesis_block(&mut storage);

let backend = InMemory::from(storage);
// TODO EMCH need to put kv in genesis
let backend = InMemory::from((storage.0, storage.1, Default::default()));
let (b1data, _b1hash) = block1(genesis_hash, &backend);

let mut overlay = OverlayedChanges::default();
Expand Down Expand Up @@ -222,7 +224,8 @@ mod tests {
).genesis_map();
let genesis_hash = insert_genesis_block(&mut storage);

let backend = InMemory::from(storage);
// TODO EMCH need to put kv in genesis
let backend = InMemory::from((storage.0, storage.1, Default::default()));
let (b1data, _b1hash) = block1(genesis_hash, &backend);

let mut overlay = OverlayedChanges::default();
Expand Down
12 changes: 11 additions & 1 deletion core/client/src/light/backend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ use std::collections::HashMap;
use std::sync::Arc;
use parking_lot::{RwLock, Mutex};

use primitives::child_trie::KeySpace;
use sr_primitives::{generic::BlockId, Justification, StorageOverlay, ChildrenStorageOverlay};
use state_machine::{Backend as StateBackend, TrieBackend, backend::InMemory as InMemoryState, ChangesTrieTransaction};
use sr_primitives::traits::{Block as BlockT, NumberFor, Zero, Header};
Expand Down Expand Up @@ -290,7 +291,8 @@ where
storage.insert(Some(child_key), child_storage);
}

let storage_update: InMemoryState<H> = storage.into();
// TODO EMCH need kv init here
let storage_update: InMemoryState<H> = (storage, Default::default()).into();
let (storage_root, _) = storage_update.full_storage_root(
::std::iter::empty(),
child_delta,
Expand Down Expand Up @@ -362,6 +364,14 @@ impl<H: Hasher> StateBackend<H> for GenesisOrUnavailableState<H>
}
}

fn get_child_keyspace(&self, storage_key: &[u8]) -> ClientResult<Option<KeySpace>> {
match *self {
GenesisOrUnavailableState::Genesis(ref state) =>
Ok(state.get_child_keyspace(storage_key).expect(IN_MEMORY_EXPECT_PROOF)),
GenesisOrUnavailableState::Unavailable => Err(ClientError::NotAvailableOnLightClient),
}
}

fn for_keys_with_prefix<A: FnMut(&[u8])>(&self, prefix: &[u8], action: A) {
match *self {
GenesisOrUnavailableState::Genesis(ref state) => state.for_keys_with_prefix(prefix, action),
Expand Down
4 changes: 2 additions & 2 deletions core/executor/src/wasm_executor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1667,7 +1667,7 @@ mod tests {
b"input".to_vec() => b"Hello world".to_vec(),
b"foo".to_vec() => b"bar".to_vec(),
b"baz".to_vec() => b"bar".to_vec()
], map![]));
], map![], map![]));
assert_eq!(ext, expected);
}

Expand All @@ -1690,7 +1690,7 @@ mod tests {
b"aaa".to_vec() => b"1".to_vec(),
b"aab".to_vec() => b"2".to_vec(),
b"bbb".to_vec() => b"5".to_vec()
], map![]));
], map![], map![]));
assert_eq!(expected, ext);
}

Expand Down
Loading