Offchain execution extensions (#4145)

* Pass Extensions instead of individual objects.

* Move TransactionPool to a separate ExternalitiesExtension.

* Fix compilation.?

* Clean up.

* Refactor testing utilities.

* Add docs, fix tests.

* Fix doctest.

* Fix formatting and add some logs.

* Add some docs.

* Remove unused files.
This commit is contained in:
Tomasz Drwięga
2019-11-22 17:10:23 +01:00
committed by Gavin Wood
parent f000392cc0
commit 86b6ac5571
39 changed files with 554 additions and 360 deletions
+6 -6
View File
@@ -39,11 +39,12 @@ use std::path::PathBuf;
use std::io;
use std::collections::{HashMap, HashSet};
use client_api::ForkBlocks;
use client_api::backend::NewBlockState;
use client_api::blockchain::{well_known_cache_keys, HeaderBackend};
use client_api::{ForkBlocks, ExecutionStrategies};
use client_api::backend::{StorageCollection, ChildStorageCollection};
use client_api::blockchain::{well_known_cache_keys, HeaderBackend};
use client_api::error::{Result as ClientResult, Error as ClientError};
use client_api::execution_extensions::ExecutionExtensions;
use codec::{Decode, Encode};
use hash_db::{Hasher, Prefix};
use kvdb::{KeyValueDB, DBTransaction};
@@ -224,8 +225,7 @@ pub fn new_client<E, S, Block, RA>(
executor: E,
genesis_storage: S,
fork_blocks: ForkBlocks<Block>,
execution_strategies: ExecutionStrategies,
keystore: Option<primitives::traits::BareCryptoStorePtr>,
execution_extensions: ExecutionExtensions<Block>,
) -> Result<(
client::Client<
Backend<Block>,
@@ -243,9 +243,9 @@ pub fn new_client<E, S, Block, RA>(
S: BuildStorage,
{
let backend = Arc::new(Backend::new(settings, CANONICALIZATION_DELAY)?);
let executor = client::LocalCallExecutor::new(backend.clone(), executor, keystore);
let executor = client::LocalCallExecutor::new(backend.clone(), executor);
Ok((
client::Client::new(backend.clone(), executor, genesis_storage, fork_blocks, execution_strategies)?,
client::Client::new(backend.clone(), executor, genesis_storage, fork_blocks, execution_extensions)?,
backend,
))
}
+2 -2
View File
@@ -56,7 +56,7 @@ impl LocalStorage {
}
}
impl client_api::OffchainStorage for LocalStorage {
impl primitives::offchain::OffchainStorage for LocalStorage {
fn set(&mut self, prefix: &[u8], key: &[u8], value: &[u8]) {
let key: Vec<u8> = prefix.iter().chain(key).cloned().collect();
let mut tx = self.db.transaction();
@@ -117,7 +117,7 @@ impl client_api::OffchainStorage for LocalStorage {
#[cfg(test)]
mod tests {
use super::*;
use client_api::OffchainStorage;
use primitives::offchain::OffchainStorage;
#[test]
fn should_compare_and_set_and_clear_the_locks_map() {