Skip to content

Commit 7a6dc6e

Browse files
committed
Revert "Inner hashing of value in state trie (runtime versioning). (paritytech#9732)"
This reverts commit b03e8bc.
1 parent 1d2fe38 commit 7a6dc6e

File tree

78 files changed

+773
-1805
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

78 files changed

+773
-1805
lines changed

Cargo.lock

Lines changed: 9 additions & 21 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

bin/node-template/runtime/src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,6 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
102102
impl_version: 1,
103103
apis: RUNTIME_API_VERSIONS,
104104
transaction_version: 1,
105-
state_version: 1,
106105
};
107106

108107
/// This determines the average expected block time that we are targeting.

bin/node/bench/src/generator.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ use std::{collections::HashMap, sync::Arc};
2020

2121
use kvdb::KeyValueDB;
2222
use node_primitives::Hash;
23-
use sp_trie::{trie_types::TrieDBMutV1, TrieMut};
23+
use sp_trie::{trie_types::TrieDBMut, TrieMut};
2424

2525
use crate::simple_trie::SimpleTrie;
2626

@@ -43,7 +43,8 @@ pub fn generate_trie(
4343
);
4444
let mut trie = SimpleTrie { db, overlay: &mut overlay };
4545
{
46-
let mut trie_db = TrieDBMutV1::<crate::simple_trie::Hasher>::new(&mut trie, &mut root);
46+
let mut trie_db = TrieDBMut::new(&mut trie, &mut root);
47+
4748
for (key, value) in key_values {
4849
trie_db.insert(&key, &value).expect("trie insertion failed");
4950
}

bin/node/bench/src/trie.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ use kvdb::KeyValueDB;
2323
use lazy_static::lazy_static;
2424
use rand::Rng;
2525
use sp_state_machine::Backend as _;
26-
use sp_trie::{trie_types::TrieDBMutV1, TrieMut as _};
26+
use sp_trie::{trie_types::TrieDBMut, TrieMut as _};
2727
use std::{borrow::Cow, collections::HashMap, sync::Arc};
2828

2929
use node_primitives::Hash;
@@ -286,8 +286,8 @@ impl core::Benchmark for TrieWriteBenchmark {
286286

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

292292
for (warmup_key, warmup_value) in self.warmup_keys.iter() {
293293
let value = trie_db_mut

bin/node/executor/benches/bench.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,14 +83,14 @@ fn construct_block<E: Externalities>(
8383
parent_hash: Hash,
8484
extrinsics: Vec<CheckedExtrinsic>,
8585
) -> (Vec<u8>, Hash) {
86-
use sp_trie::{LayoutV0, TrieConfiguration};
86+
use sp_trie::{trie_types::Layout, TrieConfiguration};
8787

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

9191
// calculate the header fields that we can.
9292
let extrinsics_root =
93-
LayoutV0::<BlakeTwo256>::ordered_trie_root(extrinsics.iter().map(Encode::encode))
93+
Layout::<BlakeTwo256>::ordered_trie_root(extrinsics.iter().map(Encode::encode))
9494
.to_fixed_bytes()
9595
.into();
9696

bin/node/executor/tests/common.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ pub fn construct_block(
142142
extrinsics: Vec<CheckedExtrinsic>,
143143
babe_slot: Slot,
144144
) -> (Vec<u8>, Hash) {
145-
use sp_trie::{LayoutV1 as Layout, TrieConfiguration};
145+
use sp_trie::{trie_types::Layout, TrieConfiguration};
146146

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

bin/node/runtime/src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,6 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
127127
impl_version: 0,
128128
apis: RUNTIME_API_VERSIONS,
129129
transaction_version: 2,
130-
state_version: 1,
131130
};
132131

133132
/// The BABE epoch configuration at genesis.

client/api/src/backend.rs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ use sp_core::offchain::OffchainStorage;
2929
use sp_runtime::{
3030
generic::BlockId,
3131
traits::{Block as BlockT, HashFor, NumberFor},
32-
Justification, Justifications, StateVersion, Storage,
32+
Justification, Justifications, Storage,
3333
};
3434
use sp_state_machine::{
3535
ChildStorageCollection, IndexOperation, OffchainChangesCollection, StorageCollection,
@@ -178,15 +178,10 @@ pub trait BlockImportOperation<Block: BlockT> {
178178
&mut self,
179179
storage: Storage,
180180
commit: bool,
181-
state_version: StateVersion,
182181
) -> sp_blockchain::Result<Block::Hash>;
183182

184183
/// Inject storage data into the database replacing any existing data.
185-
fn reset_storage(
186-
&mut self,
187-
storage: Storage,
188-
state_version: StateVersion,
189-
) -> sp_blockchain::Result<Block::Hash>;
184+
fn reset_storage(&mut self, storage: Storage) -> sp_blockchain::Result<Block::Hash>;
190185

191186
/// Set storage changes.
192187
fn update_storage(

client/api/src/call_executor.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
//! A method call executor interface.
2020
2121
use codec::{Decode, Encode};
22-
use sc_executor::{RuntimeVersion, RuntimeVersionOf};
22+
use sc_executor::RuntimeVersion;
2323
use sp_core::NativeOrEncoded;
2424
use sp_externalities::Extensions;
2525
use sp_runtime::{generic::BlockId, traits::Block as BlockT};
@@ -42,7 +42,7 @@ pub trait ExecutorProvider<Block: BlockT> {
4242
}
4343

4444
/// Method call executor.
45-
pub trait CallExecutor<B: BlockT>: RuntimeVersionOf {
45+
pub trait CallExecutor<B: BlockT> {
4646
/// Externalities error type.
4747
type Error: sp_state_machine::Error;
4848

client/api/src/in_mem.rs

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ use sp_core::{
2626
use sp_runtime::{
2727
generic::BlockId,
2828
traits::{Block as BlockT, HashFor, Header as HeaderT, NumberFor, Zero},
29-
Justification, Justifications, StateVersion, Storage,
29+
Justification, Justifications, Storage,
3030
};
3131
use sp_state_machine::{
3232
Backend as StateBackend, ChildStorageCollection, InMemoryBackend, IndexOperation,
@@ -506,7 +506,6 @@ where
506506
&mut self,
507507
storage: Storage,
508508
commit: bool,
509-
state_version: StateVersion,
510509
) -> sp_blockchain::Result<Block::Hash> {
511510
check_genesis_storage(&storage)?;
512511

@@ -520,7 +519,6 @@ where
520519
let (root, transaction) = self.old_state.full_storage_root(
521520
storage.top.iter().map(|(k, v)| (k.as_ref(), Some(v.as_ref()))),
522521
child_delta,
523-
state_version,
524522
);
525523

526524
if commit {
@@ -568,17 +566,12 @@ where
568566
&mut self,
569567
storage: Storage,
570568
commit: bool,
571-
state_version: StateVersion,
572569
) -> sp_blockchain::Result<Block::Hash> {
573-
self.apply_storage(storage, commit, state_version)
570+
self.apply_storage(storage, commit)
574571
}
575572

576-
fn reset_storage(
577-
&mut self,
578-
storage: Storage,
579-
state_version: StateVersion,
580-
) -> sp_blockchain::Result<Block::Hash> {
581-
self.apply_storage(storage, true, state_version)
573+
fn reset_storage(&mut self, storage: Storage) -> sp_blockchain::Result<Block::Hash> {
574+
self.apply_storage(storage, true)
582575
}
583576

584577
fn insert_aux<I>(&mut self, ops: I) -> sp_blockchain::Result<()>

0 commit comments

Comments
 (0)