diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 7d1debb2fc09b..d865c6d13068d 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -113,9 +113,12 @@ cargo-check-benches:
<<: *docker-env
script:
- BUILD_DUMMY_WASM_BINARY=1 time cargo +nightly check --benches --all
+ - cd ./primitives/state-machine/fuzz
+ - time cargo check
- sccache -s
+
cargo-check-subkey:
stage: test
<<: *docker-env
diff --git a/Cargo.lock b/Cargo.lock
index cc63cf57f03e5..e3523fd09ed48 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -3590,6 +3590,7 @@ dependencies = [
"pwasm-utils 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)",
"serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)",
"sp-core 2.0.0",
+ "sp-historical-data 2.0.0",
"sp-io 2.0.0",
"sp-runtime 2.0.0",
"sp-sandbox 2.0.0",
@@ -4535,6 +4536,7 @@ dependencies = [
"rand_chacha 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
"rand_core 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
"rand_hc 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "rand_pcg 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
@@ -4642,6 +4644,14 @@ dependencies = [
"rand_core 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)",
]
+[[package]]
+name = "rand_pcg"
+version = "0.2.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+dependencies = [
+ "rand_core 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
+]
+
[[package]]
name = "rand_xorshift"
version = "0.1.1"
@@ -6255,6 +6265,14 @@ dependencies = [
"sp-std 2.0.0",
]
+[[package]]
+name = "sp-historical-data"
+version = "2.0.0"
+dependencies = [
+ "smallvec 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)",
+ "sp-std 2.0.0",
+]
+
[[package]]
name = "sp-inherents"
version = "2.0.0"
@@ -6445,6 +6463,7 @@ dependencies = [
name = "sp-state-machine"
version = "2.0.0"
dependencies = [
+ "criterion 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)",
"hash-db 0.15.2 (registry+https://github.com/rust-lang/crates.io-index)",
"hex-literal 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -6454,6 +6473,7 @@ dependencies = [
"rand 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)",
"sp-core 2.0.0",
"sp-externalities 2.0.0",
+ "sp-historical-data 2.0.0",
"sp-panic-handler 2.0.0",
"sp-trie 2.0.0",
"trie-db 0.16.0 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -6746,6 +6766,7 @@ dependencies = [
"sp-consensus-aura 2.0.0",
"sp-consensus-babe 2.0.0",
"sp-core 2.0.0",
+ "sp-historical-data 2.0.0",
"sp-inherents 2.0.0",
"sp-io 2.0.0",
"sp-keyring 2.0.0",
@@ -8424,6 +8445,7 @@ dependencies = [
"checksum rand_os 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "7b75f676a1e053fc562eafbb47838d67c84801e38fc1ba459e8f180deabd5071"
"checksum rand_os 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "a788ae3edb696cfcba1c19bfd388cc4b8c21f8a408432b199c072825084da58a"
"checksum rand_pcg 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "abf9b09b01790cfe0364f52bf32995ea3c39f4d2dd011eac241d2914146d0b44"
+"checksum rand_pcg 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "16abd0c1b639e9eb4d7c50c0b8100b0d0f849be2349829c740fe8e6eb4816429"
"checksum rand_xorshift 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "cbf7e9e623549b0e21f6e97cf8ecf247c1a8fd2e8a992ae265314300b2455d5c"
"checksum rand_xoshiro 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "03b418169fb9c46533f326efd6eed2576699c44ca92d3052a066214a8d828929"
"checksum rand_xoshiro 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0e18c91676f670f6f0312764c759405f13afb98d5d73819840cf72a518487bff"
diff --git a/Cargo.toml b/Cargo.toml
index 84f412851556d..38554c3b73af4 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -124,6 +124,7 @@ members = [
"primitives/api/proc-macro",
"primitives/api/test",
"primitives/arithmetic",
+ "primitives/historical-data",
"primitives/io",
"primitives/runtime",
"primitives/sandbox",
diff --git a/frame/contracts/Cargo.toml b/frame/contracts/Cargo.toml
index b5bd460dee14f..c9ed9f8f46cb1 100644
--- a/frame/contracts/Cargo.toml
+++ b/frame/contracts/Cargo.toml
@@ -14,6 +14,7 @@ primitives = { package = "sp-core", path = "../../primitives/core", default-fea
sp-runtime = { path = "../../primitives/runtime", default-features = false }
sp-io = { path = "../../primitives/io", default-features = false }
sp-std = { path = "../../primitives/std", default-features = false }
+sp-historical-data = { path = "../../primitives/historical-data", default-features = false }
sandbox = { package = "sp-sandbox", path = "../../primitives/sandbox", default-features = false }
support = { package = "frame-support", path = "../support", default-features = false }
system = { package = "frame-system", path = "../system", default-features = false }
@@ -35,6 +36,7 @@ std = [
"sp-runtime/std",
"sp-io/std",
"sp-std/std",
+ "sp-historical-data/std",
"sandbox/std",
"support/std",
"system/std",
diff --git a/frame/contracts/src/account_db.rs b/frame/contracts/src/account_db.rs
deleted file mode 100644
index 2971f46f375c2..0000000000000
--- a/frame/contracts/src/account_db.rs
+++ /dev/null
@@ -1,391 +0,0 @@
-// Copyright 2018-2019 Parity Technologies (UK) Ltd.
-// This file is part of Substrate.
-
-// Substrate is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-
-// Substrate is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-
-// You should have received a copy of the GNU General Public License
-// along with Substrate. If not, see .
-
-//! Auxiliaries to help with managing partial changes to accounts state.
-
-use super::{
- AliveContractInfo, BalanceOf, CodeHash, ContractInfo, ContractInfoOf, Trait, TrieId,
- TrieIdGenerator,
-};
-use crate::exec::StorageKey;
-use sp_std::cell::RefCell;
-use sp_std::collections::btree_map::{BTreeMap, Entry};
-use sp_std::prelude::*;
-use sp_io::hashing::blake2_256;
-use sp_runtime::traits::{Bounded, Zero};
-use support::traits::{Currency, Get, Imbalance, SignedImbalance, UpdateBalanceOutcome};
-use support::{storage::child, StorageMap};
-use system;
-
-// Note: we don't provide Option because we can't create
-// the trie_id in the overlay, thus we provide an overlay on the fields
-// specifically.
-pub struct ChangeEntry {
- /// If Some(_), then the account balance is modified to the value. If None and `reset` is false,
- /// the balance unmodified. If None and `reset` is true, the balance is reset to 0.
- balance: Option>,
- /// If Some(_), then a contract is instantiated with the code hash. If None and `reset` is false,
- /// then the contract code is unmodified. If None and `reset` is true, the contract is deleted.
- code_hash: Option>,
- /// If Some(_), then the rent allowance is set to the value. If None and `reset` is false, then
- /// the rent allowance is unmodified. If None and `reset` is true, the contract is deleted.
- rent_allowance: Option>,
- storage: BTreeMap>>,
- /// If true, indicates that the existing contract and all its storage entries should be removed
- /// and replaced with the fields on this change entry. Otherwise, the fields on this change
- /// entry are updates merged into the existing contract info and storage.
- reset: bool,
-}
-
-impl ChangeEntry {
- fn balance(&self) -> Option> {
- self.balance.or_else(|| {
- if self.reset {
- Some(>::zero())
- } else {
- None
- }
- })
- }
-
- fn code_hash(&self) -> Option