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 all commits
Commits
Show all changes
132 commits
Select commit Hold shift + click to select a range
e026ea6
starting
cheme May 17, 2021
5b1c550
Updated from other branch.
cheme May 18, 2021
7e98291
setting flag
cheme May 18, 2021
5d3a1b2
flag in storage struct
cheme May 18, 2021
4256a40
fix flagging to access and insert.
cheme May 18, 2021
5bb0b68
added todo to fix
cheme May 18, 2021
7081864
also missing serialize meta to storage proof
cheme May 18, 2021
3f1ee83
extract meta.
cheme May 19, 2021
1bbdf35
Isolate old trie layout.
cheme May 19, 2021
e5feabf
failing test that requires storing in meta when old hash scheme is used.
cheme May 19, 2021
aa78ed6
old hash compatibility
cheme May 19, 2021
045b097
Db migrate.
cheme May 19, 2021
79a43dd
runing tests with both states when interesting.
cheme May 20, 2021
aa2e5c3
fix chain spec test with serde default.
cheme May 20, 2021
91bd0aa
export state (missing trie function).
cheme May 20, 2021
183b7b5
Pending using new branch, lacking genericity on layout resolution.
cheme May 21, 2021
8511a40
extract and set global meta
cheme May 21, 2021
270ed28
Update to branch 4
cheme May 24, 2021
b838e7e
fix iterator with root flag (no longer insert node).
cheme May 25, 2021
30742b7
fix trie root hashing of root
cheme May 25, 2021
c620869
complete basic backend.
cheme May 26, 2021
a3b1039
Remove old_hash meta from proof that do not use inner_hashing.
cheme May 26, 2021
693e38b
fix trie test for empty (force layout on empty deltas).
cheme May 26, 2021
6e89b3a
Root update fix.
cheme May 26, 2021
c14e11c
Merge branch 'master' into state-update4
cheme May 26, 2021
f568794
debug on meta
cheme May 26, 2021
fb0ea03
Use trie key iteration that do not include value in proofs.
cheme May 27, 2021
cd98390
switch default test ext to use inner hash.
cheme May 27, 2021
5ab0c01
small integration test, and fix tx cache mgmt in ext.
cheme May 27, 2021
99ef85c
Proof scenario at state-machine level.
cheme May 27, 2021
4d6aee8
trace for db upgrade
cheme May 27, 2021
791acae
try different param
cheme May 27, 2021
b51eaa4
act more like iter_from.
cheme May 28, 2021
715b1a5
Bigger batches.
cheme May 28, 2021
3cdb0ed
Update trie dependency.
cheme May 28, 2021
ae1454f
drafting codec changes and refact
cheme Jun 8, 2021
c807f44
before removing unused branch no value alt hashing.
cheme Jun 8, 2021
a70ce70
alt hashing only for branch with value.
cheme Jun 8, 2021
11f0d5a
fix trie tests
cheme Jun 8, 2021
cf0f0df
Hash of value include the encoded size.
cheme Jun 8, 2021
b721733
removing fields(broken)
cheme Jun 9, 2021
2f8360f
fix trie_stream to also include value length in inner hash.
cheme Jun 9, 2021
76b6d7a
triedbmut only using alt type if inner hashing.
cheme Jun 9, 2021
cfa0ecd
trie_stream to also only use alt hashing type when actually alt hashing.
cheme Jun 9, 2021
60f7012
Refactor meta state, logic should work with change of trie treshold.
cheme Jun 9, 2021
40ec2f7
Remove NoMeta variant.
cheme Jun 9, 2021
204f51f
Remove state_hashed trigger specific functions.
cheme Jun 9, 2021
b62cdf5
pending switching to using threshold, new storage root api does not
cheme Jun 10, 2021
74fb9c8
refactoring to use state from backend (not possible payload changes).
cheme Jun 10, 2021
97a1aa6
Applying from previous state
cheme Jun 10, 2021
f4849a2
Remove default from storage, genesis need a special build.
cheme Jun 10, 2021
4eabbde
rem empty space
cheme Jun 11, 2021
18abb6e
Merge branch 'master' into state-update4-refact
cheme Jun 11, 2021
ae627f6
Catch problem: when using triedb with default: we should not revert
cheme Jun 11, 2021
4706814
fix compilation
cheme Jun 11, 2021
09d5cf6
Right logic to avoid switch on reencode when default layout.
cheme Jun 11, 2021
906cd48
Clean up some todos
cheme Jun 14, 2021
662eabe
remove trie meta from root upstream
cheme Jun 14, 2021
17ac7cb
Merge branch 'master' into state-update4-refact
cheme Jun 15, 2021
ac0e019
update upstream and fix benches.
cheme Jun 15, 2021
7e73a70
split some long lines.
cheme Jun 15, 2021
3498d17
Merge branch 'master' into state-update4-refact
cheme Jun 15, 2021
934021c
UPdate trie crate to work with new design.
cheme Jun 18, 2021
1e40e6d
Finish update to refactored upstream.
cheme Jun 21, 2021
602723e
update to latest triedb changes.
cheme Jun 21, 2021
66ee72d
Clean up.
cheme Jun 21, 2021
23c5db3
fix executor test.
cheme Jun 21, 2021
03d93b2
rust fmt from master.
cheme Jul 22, 2021
b13ebd0
Merge branch 'master' into state-update4
cheme Jul 22, 2021
93aaa4c
rust format.
cheme Jul 22, 2021
66c832e
Merge branch 'master' into state-update4
cheme Aug 11, 2021
89eba2b
Merge branch 'master' into state-update4
cheme Aug 16, 2021
1e02c01
rustfmt
cheme Aug 16, 2021
7898e49
Merge branch 'master' into state-update4
cheme Aug 27, 2021
a48970f
fix
cheme Aug 27, 2021
92b9fcf
start host function driven versioning
cheme Aug 27, 2021
145406a
update state-machine part
cheme Aug 30, 2021
00460da
still need access to state version from runtime
cheme Aug 31, 2021
bad0723
state hash in mem: wrong
cheme Aug 31, 2021
537c04f
direction likely correct, but passing call to code exec for genesis
cheme Aug 31, 2021
b537440
state version serialize in runtime, wrong approach, just initialize it
cheme Sep 8, 2021
b717611
stateversion from runtime version (core api >= 4).
cheme Sep 8, 2021
b6a6e83
Merge branch 'master' into state-update4-host2
cheme Sep 8, 2021
846fef0
update trie, fix tests
cheme Sep 8, 2021
0a6dc15
unused import
cheme Sep 8, 2021
4e10a68
clean some TODOs
cheme Sep 8, 2021
bf31362
Require RuntimeVersionOf for executor
cheme Sep 8, 2021
8aba5dd
use RuntimeVersionOf to resolve genesis state version.
cheme Sep 8, 2021
499ab5b
update runtime version test
cheme Sep 8, 2021
27cf136
fix state-machine tests
cheme Sep 8, 2021
ac4f7dc
TODO
cheme Sep 8, 2021
1c817d6
Use runtime version from storage wasm with fast sync.
cheme Sep 9, 2021
f0d9326
rustfmt
cheme Sep 9, 2021
6d930fa
Merge branch 'master' into state-update4-host2
cheme Sep 9, 2021
877c36e
fmt
cheme Sep 9, 2021
8514d5f
fix test
cheme Sep 9, 2021
3385eae
revert useless changes.
cheme Sep 9, 2021
3be7538
clean some unused changes
cheme Sep 9, 2021
c858c28
fmt
cheme Sep 9, 2021
44f9168
Adapt to state_version in host.
cheme Sep 10, 2021
dc92f1a
fix stress seed init
cheme Sep 10, 2021
63265eb
removing useless trait function.
cheme Sep 10, 2021
6ced7ba
Reserved key and configuration where test fail to debug
cheme Sep 10, 2021
6044e0d
just an incorrect assertion (if last value are of unhashed size, the
cheme Sep 10, 2021
8d78b14
correct calculation in case of reserve only state.
cheme Sep 10, 2021
4142b8d
remove remaining reference to state_hash
cheme Sep 14, 2021
b3c8812
Merge branch 'state-update4-host2' of github.com:cheme/substrate into…
cheme Sep 14, 2021
aac1ecb
Use cost instead of weight so benchmarking could make sense.
cheme Sep 15, 2021
3b88fdd
Revert "Use cost instead of weight so benchmarking could make sense."
cheme Sep 15, 2021
f1931ec
use constant macro
cheme Sep 15, 2021
c837f1a
right bound
cheme Sep 15, 2021
d141b53
Merge branch 'master' into state-update4-migrationruntime
cheme Sep 20, 2021
fa7fb65
Merge branch 'master' into state-update4-migrationruntime
cheme Oct 1, 2021
33e70a6
Follow chain state version management.
cheme Oct 1, 2021
aaca0f8
Merge branch 'master' into state-update4-host2
cheme Oct 1, 2021
5ed824a
fix some imports
cheme Oct 1, 2021
b0b8a85
Follow chain state version management.
cheme Oct 1, 2021
c223489
Merge branch 'state-update4-host2' into state-update4-migrationruntime
cheme Oct 1, 2021
e7267c0
trie update, fix and constant threshold for trie layouts.
cheme Oct 4, 2021
599714f
update deps
cheme Oct 4, 2021
6045952
Update to latest trie pr changes.
cheme Oct 5, 2021
fb8ff8e
fix benches
cheme Oct 5, 2021
af86f39
Verify proof requires right layout.
cheme Oct 5, 2021
66daec0
update trie_root
cheme Oct 7, 2021
299fea6
Merge branch 'master' into state-update4-host2
cheme Oct 12, 2021
8b8b71b
Merge branch 'master' into state-update4-migrationruntime
cheme Oct 12, 2021
4ff9009
Update trie deps to latest
cheme Oct 12, 2021
ea0d8f6
base code for inherent driven runtime migration
cheme Oct 14, 2021
244b5c5
Correct call through runtime api and pallet in test.
cheme Oct 14, 2021
9479d77
Fix node executor test to skip migration.
cheme Oct 14, 2021
fa0b5df
recheck comments, fmt, rem dead code.
cheme Oct 15, 2021
4c42b43
Merge branch 'state-update4-host2' into state-update4-migrationruntime
cheme Oct 15, 2021
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
82 changes: 63 additions & 19 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 9 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ members = [
"frame/staking",
"frame/staking/reward-curve",
"frame/staking/reward-fn",
"frame/state-migrate-0-to-1",
"frame/sudo",
"frame/support",
"frame/support/procedural",
Expand Down Expand Up @@ -271,4 +272,11 @@ yamux = { opt-level = 3 }
zeroize = { opt-level = 3 }
[profile.release]
# Substrate runtime requires unwinding.
panic = "unwind"
panic = "unwind"

[patch.crates-io]
hash-db = { git = "https://github.com/cheme/trie.git", branch = "hashed-value-simple4-new" }
memory-db = { git = "https://github.com/cheme/trie.git", branch = "hashed-value-simple4-new" }
trie-db = { git = "https://github.com/cheme/trie.git", branch = "hashed-value-simple4-new" }
trie-root = { git = "https://github.com/cheme/trie.git", branch = "hashed-value-simple4-new" }
trie-bench = { git = "https://github.com/cheme/trie.git", branch = "hashed-value-simple4-new" }
5 changes: 2 additions & 3 deletions bin/node/bench/src/generator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ use std::{collections::HashMap, sync::Arc};

use kvdb::KeyValueDB;
use node_primitives::Hash;
use sp_trie::{trie_types::TrieDBMut, TrieMut};
use sp_trie::{trie_types::TrieDBMutV1, TrieMut};

use crate::simple_trie::SimpleTrie;

Expand All @@ -43,8 +43,7 @@ pub fn generate_trie(
);
let mut trie = SimpleTrie { db, overlay: &mut overlay };
{
let mut trie_db = TrieDBMut::new(&mut trie, &mut root);

let mut trie_db = TrieDBMutV1::<crate::simple_trie::Hasher>::new(&mut trie, &mut root);
for (key, value) in key_values {
trie_db.insert(&key, &value).expect("trie insertion failed");
}
Expand Down
6 changes: 3 additions & 3 deletions bin/node/bench/src/trie.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ use kvdb::KeyValueDB;
use lazy_static::lazy_static;
use rand::Rng;
use sp_state_machine::Backend as _;
use sp_trie::{trie_types::TrieDBMut, TrieMut as _};
use sp_trie::{trie_types::TrieDBMutV1, TrieMut as _};
use std::{borrow::Cow, collections::HashMap, sync::Arc};

use node_primitives::Hash;
Expand Down Expand Up @@ -286,8 +286,8 @@ impl core::Benchmark for TrieWriteBenchmark {

let mut overlay = HashMap::new();
let mut trie = SimpleTrie { db: kvdb.clone(), overlay: &mut overlay };
let mut trie_db_mut =
TrieDBMut::from_existing(&mut trie, &mut new_root).expect("Failed to create TrieDBMut");
let mut trie_db_mut = TrieDBMutV1::from_existing(&mut trie, &mut new_root)
.expect("Failed to create TrieDBMut");

for (warmup_key, warmup_value) in self.warmup_keys.iter() {
let value = trie_db_mut
Expand Down
8 changes: 7 additions & 1 deletion bin/node/cli/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,13 @@ pub fn new_full_base(
&parent,
)?;

Ok((timestamp, slot, uncles, storage_proof))
let state_migration =
sc_client_api::state_migration_inherents::new_migration_provider(
&*client_clone,
&parent,
)?;

Ok((timestamp, slot, uncles, storage_proof, state_migration))
}
},
force_authoring,
Expand Down
4 changes: 2 additions & 2 deletions bin/node/executor/benches/bench.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,14 +83,14 @@ fn construct_block<E: Externalities>(
parent_hash: Hash,
extrinsics: Vec<CheckedExtrinsic>,
) -> (Vec<u8>, Hash) {
use sp_trie::{trie_types::Layout, TrieConfiguration};
use sp_trie::{LayoutV0, TrieConfiguration};

// sign extrinsics.
let extrinsics = extrinsics.into_iter().map(sign).collect::<Vec<_>>();

// calculate the header fields that we can.
let extrinsics_root =
Layout::<BlakeTwo256>::ordered_trie_root(extrinsics.iter().map(Encode::encode))
LayoutV0::<BlakeTwo256>::ordered_trie_root(extrinsics.iter().map(Encode::encode))
.to_fixed_bytes()
.into();

Expand Down
8 changes: 7 additions & 1 deletion bin/node/executor/tests/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,12 @@ pub fn new_test_ext(code: &[u8], support_changes_trie: bool) -> TestExternalitie
.build_storage()
.unwrap(),
);

use sp_core::hashing::twox_128;
// set migration progress to Finished (no inherent provider),
// this could be remove when migration module got removed from test runtime.
let k = [twox_128(b"StateMigrate0To1"), twox_128(b"MigrationProgress")].concat();
ext.ext().place_storage(k, Some(vec![1u8])); // Finished encoded.
ext.changes_trie_storage().insert(0, GENESIS_HASH.into(), Default::default());
ext
}
Expand All @@ -145,7 +151,7 @@ pub fn construct_block(
extrinsics: Vec<CheckedExtrinsic>,
babe_slot: Slot,
) -> (Vec<u8>, Hash) {
use sp_trie::{trie_types::Layout, TrieConfiguration};
use sp_trie::{LayoutV1 as Layout, TrieConfiguration};

// sign extrinsics.
let extrinsics = extrinsics.into_iter().map(sign).collect::<Vec<_>>();
Expand Down
2 changes: 2 additions & 0 deletions bin/node/runtime/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ pallet-session = { version = "4.0.0-dev", features = [
pallet-session-benchmarking = { version = "4.0.0-dev", path = "../../../frame/session/benchmarking", default-features = false, optional = true }
pallet-staking = { version = "4.0.0-dev", default-features = false, path = "../../../frame/staking" }
pallet-staking-reward-curve = { version = "4.0.0-dev", default-features = false, path = "../../../frame/staking/reward-curve" }
pallet-state-migrate-0-to-1 = { version = "4.0.0-dev", default-features = false, path = "../../../frame/state-migrate-0-to-1" }
pallet-scheduler = { version = "4.0.0-dev", default-features = false, path = "../../../frame/scheduler" }
pallet-society = { version = "4.0.0-dev", default-features = false, path = "../../../frame/society" }
pallet-sudo = { version = "4.0.0-dev", default-features = false, path = "../../../frame/sudo" }
Expand Down Expand Up @@ -135,6 +136,7 @@ std = [
"pallet-multisig/std",
"pallet-identity/std",
"pallet-scheduler/std",
"pallet-state-migrate-0-to-1/std",
"node-primitives/std",
"sp-offchain/std",
"pallet-offences/std",
Expand Down
19 changes: 19 additions & 0 deletions bin/node/runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1241,6 +1241,18 @@ impl pallet_transaction_storage::Config for Runtime {
type WeightInfo = pallet_transaction_storage::weights::SubstrateWeight<Runtime>;
}

parameter_types! {
pub const MigrationWeight: Weight = 500_000_000_000;
pub const MigrationMaxSize: u32 = 300;
pub const Threshold: u32 = 33;
}

impl pallet_state_migrate_0_to_1::Config for Runtime {
type MigrationWeight = MigrationWeight;
type MigrationMaxSize = MigrationMaxSize;
type Threshold = Threshold;
}

construct_runtime!(
pub enum Runtime where
Block = Block,
Expand Down Expand Up @@ -1288,6 +1300,7 @@ construct_runtime!(
Uniques: pallet_uniques::{Pallet, Call, Storage, Event<T>},
TransactionStorage: pallet_transaction_storage::{Pallet, Call, Storage, Inherent, Config<T>, Event<T>},
BagsList: pallet_bags_list::{Pallet, Call, Storage, Event<T>},
StateMigrate0To1: pallet_state_migrate_0_to_1::{Pallet, Call, Storage, Inherent},
}
);

Expand Down Expand Up @@ -1380,6 +1393,12 @@ impl_runtime_apis! {
}
}

impl pallet_state_migrate_0_to_1::CalcPayload<Block> for Runtime {
fn calculate_pending_migration_size() -> u64 {
StateMigrate0To1::calculate_pending_migration_size()
}
}

impl sp_transaction_pool::runtime_api::TaggedTransactionQueue<Block> for Runtime {
fn validate_transaction(
source: TransactionSource,
Expand Down
2 changes: 2 additions & 0 deletions client/api/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ codec = { package = "parity-scale-codec", version = "2.0.0", default-features =
sp-consensus = { version = "0.10.0-dev", path = "../../primitives/consensus/common" }
sc-executor = { version = "0.10.0-dev", path = "../executor" }
sp-externalities = { version = "0.10.0-dev", path = "../../primitives/externalities" }
sp-inherents = { version = "4.0.0-dev", path = "../../primitives/inherents" } # This should be remove as a dependency with the state migration inherent.
async-trait = { version = "0.1.50" } # This could be remove as a dependency with the state migration inherent.
fnv = "1.0.6"
futures = "0.3.1"
hash-db = { version = "0.15.2", default-features = false }
Expand Down
Loading