Kagome
Polkadot Runtime Engine in C++17
instance_environment_factory.hpp
Go to the documentation of this file.
1 
6 #ifndef KAGOME_CORE_RUNTIME_WAVM_INSTANCE_ENVIRONMENT_FACTORY_HPP
7 #define KAGOME_CORE_RUNTIME_WAVM_INSTANCE_ENVIRONMENT_FACTORY_HPP
8 
10 
11 namespace kagome::host_api {
12  class HostApiFactory;
13 }
14 
16  class ChangesTracker;
17 }
18 
19 namespace kagome::storage::trie {
20  class TrieStorage;
21  class TrieSerializer;
22 } // namespace kagome::storage::trie
23 
24 namespace kagome::blockchain {
25  class BlockHeaderRepository;
26 }
27 
28 namespace WAVM::Runtime {
29  struct Instance;
30 }
31 
32 namespace kagome::runtime {
33  class SingleModuleCache;
34  class RuntimePropertiesCache;
35 } // namespace kagome::runtime
36 
37 namespace kagome::runtime::wavm {
38  class IntrinsicModule;
39  class IntrinsicModuleInstance;
40  class IntrinsicResolver;
41  class CompartmentWrapper;
42  struct ModuleParams;
43 
45  : public std::enable_shared_from_this<InstanceEnvironmentFactory> {
46  public:
48  std::shared_ptr<storage::trie::TrieStorage> storage,
49  std::shared_ptr<storage::trie::TrieSerializer> serializer,
50  std::shared_ptr<CompartmentWrapper> compartment,
51  std::shared_ptr<ModuleParams> module_params,
52  std::shared_ptr<IntrinsicModule> intrinsic_module,
53  std::shared_ptr<host_api::HostApiFactory> host_api_factory,
54  std::shared_ptr<blockchain::BlockHeaderRepository> block_header_repo,
55  std::shared_ptr<storage::changes_trie::ChangesTracker> changes_tracker,
56  std::shared_ptr<SingleModuleCache> last_compiled_module,
57  std::shared_ptr<RuntimePropertiesCache> cache);
58 
59  enum class MemoryOrigin { EXTERNAL, INTERNAL };
60  [[nodiscard]] InstanceEnvironment make(
61  MemoryOrigin memory_origin,
62  WAVM::Runtime::Instance *runtime_instance,
63  std::shared_ptr<IntrinsicModuleInstance> intrinsic_instance) const;
64 
65  private:
66  std::shared_ptr<storage::trie::TrieStorage> storage_;
67  std::shared_ptr<storage::trie::TrieSerializer> serializer_;
68  std::shared_ptr<CompartmentWrapper> compartment_;
69  std::shared_ptr<ModuleParams> module_params_;
70  std::shared_ptr<IntrinsicModule> intrinsic_module_;
71  std::shared_ptr<host_api::HostApiFactory> host_api_factory_;
72  std::shared_ptr<blockchain::BlockHeaderRepository> block_header_repo_;
73  std::shared_ptr<storage::changes_trie::ChangesTracker> changes_tracker_;
74  std::shared_ptr<SingleModuleCache> last_compiled_module_;
75  std::shared_ptr<RuntimePropertiesCache> cache_;
76  };
77 
78 } // namespace kagome::runtime::wavm
79 
80 #endif // KAGOME_CORE_RUNTIME_WAVM_INSTANCE_ENVIRONMENT_FACTORY_HPP
std::shared_ptr< storage::trie::TrieSerializer > serializer_
std::shared_ptr< blockchain::BlockHeaderRepository > block_header_repo_
std::shared_ptr< host_api::HostApiFactory > host_api_factory_
std::shared_ptr< storage::changes_trie::ChangesTracker > changes_tracker_
std::shared_ptr< storage::trie::TrieStorage > storage_