mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-12 18:11:10 +00:00
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:
committed by
Gavin Wood
parent
f000392cc0
commit
86b6ac5571
@@ -22,12 +22,13 @@ use std::{
|
||||
|
||||
use codec::{Encode, Decode};
|
||||
use primitives::{
|
||||
offchain::OffchainExt, H256, Blake2Hasher, convert_hash, NativeOrEncoded,
|
||||
H256, Blake2Hasher, convert_hash, NativeOrEncoded,
|
||||
traits::CodeExecutor,
|
||||
};
|
||||
use sr_primitives::{
|
||||
generic::BlockId, traits::{One, Block as BlockT, Header as HeaderT, NumberFor},
|
||||
};
|
||||
use externalities::Extensions;
|
||||
use state_machine::{
|
||||
self, Backend as StateBackend, OverlayedChanges, ExecutionStrategy, create_proof_check_backend,
|
||||
execution_proof_check_on_trie_backend, ExecutionManager, ChangesTrieTransaction, StorageProof,
|
||||
@@ -84,10 +85,10 @@ impl<Block, B, Local> CallExecutor<Block, Blake2Hasher> for
|
||||
method: &str,
|
||||
call_data: &[u8],
|
||||
strategy: ExecutionStrategy,
|
||||
side_effects_handler: Option<OffchainExt>,
|
||||
extensions: Option<Extensions>,
|
||||
) -> ClientResult<Vec<u8>> {
|
||||
match self.backend.is_local_state_available(id) {
|
||||
true => self.local.call(id, method, call_data, strategy, side_effects_handler),
|
||||
true => self.local.call(id, method, call_data, strategy, extensions),
|
||||
false => Err(ClientError::NotAvailableOnLightClient),
|
||||
}
|
||||
}
|
||||
@@ -111,9 +112,8 @@ impl<Block, B, Local> CallExecutor<Block, Blake2Hasher> for
|
||||
initialize_block: InitializeBlock<'a, Block>,
|
||||
_manager: ExecutionManager<EM>,
|
||||
native_call: Option<NC>,
|
||||
side_effects_handler: Option<OffchainExt>,
|
||||
recorder: &Option<ProofRecorder<Block>>,
|
||||
enable_keystore: bool,
|
||||
extensions: Option<Extensions>,
|
||||
) -> ClientResult<NativeOrEncoded<R>> where ExecutionManager<EM>: Clone {
|
||||
// there's no actual way/need to specify native/wasm execution strategy on light node
|
||||
// => we can safely ignore passed values
|
||||
@@ -137,9 +137,8 @@ impl<Block, B, Local> CallExecutor<Block, Blake2Hasher> for
|
||||
initialize_block,
|
||||
ExecutionManager::NativeWhenPossible,
|
||||
native_call,
|
||||
side_effects_handler,
|
||||
recorder,
|
||||
enable_keystore,
|
||||
extensions,
|
||||
).map_err(|e| ClientError::Execution(Box::new(e.to_string()))),
|
||||
false => Err(ClientError::NotAvailableOnLightClient),
|
||||
}
|
||||
@@ -167,7 +166,7 @@ impl<Block, B, Local> CallExecutor<Block, Blake2Hasher> for
|
||||
_call_data: &[u8],
|
||||
_manager: ExecutionManager<FF>,
|
||||
_native_call: Option<NC>,
|
||||
_side_effects_handler: Option<OffchainExt>,
|
||||
_extensions: Option<Extensions>,
|
||||
) -> ClientResult<(
|
||||
NativeOrEncoded<R>,
|
||||
(S::Transaction, <Blake2Hasher as Hasher>::Out),
|
||||
@@ -313,7 +312,7 @@ mod tests {
|
||||
_method: &str,
|
||||
_call_data: &[u8],
|
||||
_strategy: ExecutionStrategy,
|
||||
_side_effects_handler: Option<OffchainExt>,
|
||||
_extensions: Option<Extensions>,
|
||||
) -> Result<Vec<u8>, ClientError> {
|
||||
Ok(vec![42])
|
||||
}
|
||||
@@ -337,9 +336,8 @@ mod tests {
|
||||
_initialize_block: InitializeBlock<'a, Block>,
|
||||
_execution_manager: ExecutionManager<EM>,
|
||||
_native_call: Option<NC>,
|
||||
_side_effects_handler: Option<OffchainExt>,
|
||||
_proof_recorder: &Option<ProofRecorder<Block>>,
|
||||
_enable_keystore: bool,
|
||||
_extensions: Option<Extensions>,
|
||||
) -> ClientResult<NativeOrEncoded<R>> where ExecutionManager<EM>: Clone {
|
||||
unreachable!()
|
||||
}
|
||||
@@ -363,7 +361,7 @@ mod tests {
|
||||
_call_data: &[u8],
|
||||
_manager: ExecutionManager<F>,
|
||||
_native_call: Option<NC>,
|
||||
_side_effects_handler: Option<OffchainExt>,
|
||||
_extensions: Option<Extensions>,
|
||||
) -> Result<
|
||||
(
|
||||
NativeOrEncoded<R>,
|
||||
|
||||
Reference in New Issue
Block a user