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
+5 -3
View File
@@ -24,8 +24,8 @@ use transaction_pool::{
FullChainApi,
};
use primitives::{
H256, blake2_256, hexdisplay::HexDisplay, traits::BareCryptoStore,
testing::{ED25519, SR25519, KeyStore}, ed25519, crypto::Pair
H256, blake2_256, hexdisplay::HexDisplay, testing::{ED25519, SR25519, KeyStore}, ed25519,
crypto::Pair,
};
use test_client::{
self, AccountKeyring, runtime::{Extrinsic, Transfer, SessionKeys}, DefaultTestClientBuilderExt,
@@ -212,7 +212,9 @@ fn should_insert_key() {
fn should_rotate_keys() {
let runtime = runtime::Runtime::new().unwrap();
let keystore = KeyStore::new();
let client = Arc::new(test_client::TestClientBuilder::new().set_keystore(keystore.clone()).build());
let client = Arc::new(
test_client::TestClientBuilder::new().set_keystore(keystore.clone()).build(),
);
let p = Author {
client: client.clone(),
pool: Arc::new(Pool::new(Default::default(), FullChainApi::new(client))),
+6 -4
View File
@@ -33,8 +33,7 @@ use client::{
backend::Backend, error::Result as ClientResult,
};
use primitives::{
H256, Blake2Hasher, Bytes, offchain::NeverOffchainExt,
storage::{well_known_keys, StorageKey, StorageData, StorageChangeSet},
H256, Blake2Hasher, Bytes, storage::{well_known_keys, StorageKey, StorageData, StorageChangeSet},
};
use runtime_version::RuntimeVersion;
use state_machine::ExecutionStrategy;
@@ -240,13 +239,16 @@ impl<B, E, Block, RA> StateBackend<B, E, Block, RA> for FullState<B, E, Block, R
) -> FutureResult<Bytes> {
Box::new(result(
self.block_or_best(block)
.and_then(|block| self.client.executor()
.and_then(|block|
self
.client
.executor()
.call(
&BlockId::Hash(block),
&method,
&*call_data,
ExecutionStrategy::NativeElseWasm,
NeverOffchainExt::new(),
None,
)
.map(Into::into))
.map_err(client_err)))