soil_client/client_api/
call_executor.rs1use crate::executor::{RuntimeVersion, RuntimeVersionOf};
10use std::cell::RefCell;
11use subsoil::core::traits::CallContext;
12use subsoil::externalities::Extensions;
13use subsoil::runtime::traits::{Block as BlockT, HashingFor};
14use subsoil::state_machine::{OverlayedChanges, StorageProof};
15
16use super::execution_extensions::ExecutionExtensions;
17use subsoil::api::ProofRecorder;
18
19pub trait ExecutorProvider<Block: BlockT> {
21 type Executor: CallExecutor<Block>;
23
24 fn executor(&self) -> &Self::Executor;
26
27 fn execution_extensions(&self) -> &ExecutionExtensions<Block>;
29}
30
31pub trait CallExecutor<B: BlockT>: RuntimeVersionOf {
33 type Error: subsoil::state_machine::Error;
35
36 type Backend: super::backend::Backend<B>;
38
39 fn execution_extensions(&self) -> &ExecutionExtensions<B>;
41
42 fn call(
46 &self,
47 at_hash: B::Hash,
48 method: &str,
49 call_data: &[u8],
50 context: CallContext,
51 ) -> Result<Vec<u8>, crate::blockchain::Error>;
52
53 fn contextual_call(
59 &self,
60 at_hash: B::Hash,
61 method: &str,
62 call_data: &[u8],
63 changes: &RefCell<OverlayedChanges<HashingFor<B>>>,
64 proof_recorder: &Option<ProofRecorder<B>>,
65 call_context: CallContext,
66 extensions: &RefCell<Extensions>,
67 ) -> crate::blockchain::Result<Vec<u8>>;
68
69 fn runtime_version(&self, at_hash: B::Hash)
73 -> Result<RuntimeVersion, crate::blockchain::Error>;
74
75 fn prove_execution(
79 &self,
80 at_hash: B::Hash,
81 method: &str,
82 call_data: &[u8],
83 ) -> Result<(Vec<u8>, StorageProof), crate::blockchain::Error>;
84}