Move Externalities into its own crate (#3775)

* Move `Externalities` into `substrate-externalities`

- `Externalities` now support generic extensions
- Split of `primtives-storage` for storage primitive types

* Move the externalities scoping into `substrate-externalities`

* Fix compilation

* Review feedback

* Adds macro for declaring extensions

* Fix benchmarks

* Introduce `ExtensionStore` trait

* Last review comments

* Implement it for `ExtensionStore`
This commit is contained in:
Bastian Köcher
2019-10-09 15:50:30 +02:00
committed by GitHub
parent 984c6ac839
commit 8a39be474e
95 changed files with 1600 additions and 1420 deletions
+12 -12
View File
@@ -593,9 +593,9 @@ mod tests {
use wabt;
use runtime_test::WASM_BINARY;
type TestExternalities<H> = CoreTestExternalities<H, u64>;
type TestExternalities = CoreTestExternalities<Blake2Hasher, u64>;
fn call_wasm<E: Externalities<Blake2Hasher>>(
fn call_wasm<E: Externalities>(
ext: &mut E,
heap_pages: u64,
code: &[u8],
@@ -609,7 +609,7 @@ mod tests {
#[test]
fn sandbox_should_work() {
let mut ext = TestExternalities::<Blake2Hasher>::default();
let mut ext = TestExternalities::default();
let test_code = WASM_BINARY;
let code = wabt::wat2wasm(r#"
@@ -641,7 +641,7 @@ mod tests {
#[test]
fn sandbox_trap() {
let mut ext = TestExternalities::<Blake2Hasher>::default();
let mut ext = TestExternalities::default();
let test_code = WASM_BINARY;
let code = wabt::wat2wasm(r#"
@@ -662,7 +662,7 @@ mod tests {
#[test]
fn sandbox_should_trap_when_heap_exhausted() {
let mut ext = TestExternalities::<Blake2Hasher>::default();
let mut ext = TestExternalities::default();
let test_code = WASM_BINARY;
let code = wabt::wat2wasm(r#"
@@ -690,7 +690,7 @@ mod tests {
#[test]
fn start_called() {
let mut ext = TestExternalities::<Blake2Hasher>::default();
let mut ext = TestExternalities::default();
let test_code = WASM_BINARY;
let code = wabt::wat2wasm(r#"
@@ -728,7 +728,7 @@ mod tests {
#[test]
fn invoke_args() {
let mut ext = TestExternalities::<Blake2Hasher>::default();
let mut ext = TestExternalities::default();
let test_code = WASM_BINARY;
let code = wabt::wat2wasm(r#"
@@ -762,7 +762,7 @@ mod tests {
#[test]
fn return_val() {
let mut ext = TestExternalities::<Blake2Hasher>::default();
let mut ext = TestExternalities::default();
let test_code = WASM_BINARY;
let code = wabt::wat2wasm(r#"
@@ -784,7 +784,7 @@ mod tests {
#[test]
fn unlinkable_module() {
let mut ext = TestExternalities::<Blake2Hasher>::default();
let mut ext = TestExternalities::default();
let test_code = WASM_BINARY;
let code = wabt::wat2wasm(r#"
@@ -804,7 +804,7 @@ mod tests {
#[test]
fn corrupted_module() {
let mut ext = TestExternalities::<Blake2Hasher>::default();
let mut ext = TestExternalities::default();
let test_code = WASM_BINARY;
// Corrupted wasm file
@@ -818,7 +818,7 @@ mod tests {
#[test]
fn start_fn_ok() {
let mut ext = TestExternalities::<Blake2Hasher>::default();
let mut ext = TestExternalities::default();
let test_code = WASM_BINARY;
let code = wabt::wat2wasm(r#"
@@ -841,7 +841,7 @@ mod tests {
#[test]
fn start_fn_traps() {
let mut ext = TestExternalities::<Blake2Hasher>::default();
let mut ext = TestExternalities::default();
let test_code = WASM_BINARY;
let code = wabt::wat2wasm(r#"