Kagome
Polkadot Runtime Engine in C++17
intrinsic_functions.cpp
Go to the documentation of this file.
1 
7 
10 
11 namespace kagome::runtime::wavm {
12 
14 
15  static thread_local std::stack<std::shared_ptr<ModuleInstance>>
17 
19  std::shared_ptr<ModuleInstance> borrowed_runtime_instance) {
20  global_instances.emplace(std::move(borrowed_runtime_instance));
21  }
22 
24  BOOST_ASSERT(!global_instances.empty());
25  global_instances.pop();
26  }
27 
28  std::shared_ptr<ModuleInstance> peekBorrowedRuntimeInstance() {
29  BOOST_ASSERT(!global_instances.empty());
30  return global_instances.top();
31  }
32 
33  std::shared_ptr<host_api::HostApi> peekHostApi() {
34  return peekBorrowedRuntimeInstance()->getEnvironment().host_api;
35  }
36 
37 #undef WAVM_DEFINE_INTRINSIC_FUNCTION
38 // ContextRuntimeData is required by WAVM
39 #define WAVM_DEFINE_INTRINSIC_FUNCTION(Result, cName, ...) \
40  Result cName(WAVM::Runtime::ContextRuntimeData *contextRuntimeData, \
41  ##__VA_ARGS__)
42 
43 #define WAVM_DEFINE_INTRINSIC_FUNCTION_STUB(Result, cName, ...) \
44  Result cName(WAVM::Runtime::ContextRuntimeData *contextRuntimeData, \
45  ##__VA_ARGS__) { \
46  logger->warn("Unimplemented Host API function " #cName " was called"); \
47  return Result(); \
48  }
49 
51  ext_allocator_free_version_1,
52  WAVM::I32 address) {
53  return peekHostApi()->ext_allocator_free_version_1(address);
54  }
55 
57  ext_allocator_malloc_version_1,
58  WAVM::I32 size) {
59  return peekHostApi()->ext_allocator_malloc_version_1(size);
60  }
61 
63  ext_crypto_ed25519_generate_version_1,
64  WAVM::I32 keytype,
65  WAVM::I64 seed) {
66  return peekHostApi()->ext_crypto_ed25519_generate_version_1(keytype, seed);
67  }
68 
70  ext_crypto_ed25519_public_keys_version_1,
71  WAVM::I32 key_type) {
72  return peekHostApi()->ext_crypto_ed25519_public_keys_version_1(key_type);
73  }
74 
76  ext_crypto_ed25519_sign_version_1,
77  WAVM::I32 key_type,
78  WAVM::I32 key,
79  WAVM::I64 msg_data) {
80  return peekHostApi()->ext_crypto_ed25519_sign_version_1(
81  key_type, key, msg_data);
82  }
83 
85  ext_crypto_ed25519_verify_version_1,
86  WAVM::I32 sig_data,
87  WAVM::I64 msg,
88  WAVM::I32 pubkey_data) {
89  return peekHostApi()->ext_crypto_ed25519_verify_version_1(
90  sig_data, msg, pubkey_data);
91  }
92 
94  ext_crypto_finish_batch_verify_version_1) {
95  return peekHostApi()->ext_crypto_finish_batch_verify_version_1();
96  }
97 
99  ext_crypto_secp256k1_ecdsa_recover_version_1,
100  WAVM::I32 sig,
101  WAVM::I32 msg) {
102  return peekHostApi()->ext_crypto_secp256k1_ecdsa_recover_version_1(sig,
103  msg);
104  }
105 
107  ext_crypto_secp256k1_ecdsa_recover_version_2,
108  WAVM::I32 sig,
109  WAVM::I32 msg) {
110  return peekHostApi()->ext_crypto_secp256k1_ecdsa_recover_version_2(sig,
111  msg);
112  }
113 
115  WAVM::I64,
116  ext_crypto_secp256k1_ecdsa_recover_compressed_version_1,
117  WAVM::I32 sig,
118  WAVM::I32 msg) {
119  return peekHostApi()
120  ->ext_crypto_secp256k1_ecdsa_recover_compressed_version_1(sig, msg);
121  }
122 
124  WAVM::I64,
125  ext_crypto_secp256k1_ecdsa_recover_compressed_version_2,
126  WAVM::I32 sig,
127  WAVM::I32 msg) {
128  return peekHostApi()
129  ->ext_crypto_secp256k1_ecdsa_recover_compressed_version_2(sig, msg);
130  }
131 
133  ext_crypto_sr25519_generate_version_1,
134  WAVM::I32 key_type,
135  WAVM::I64 seed) {
136  return peekHostApi()->ext_crypto_sr25519_generate_version_1(key_type, seed);
137  }
138 
140  ext_crypto_sr25519_public_keys_version_1,
141  WAVM::I32 key_type) {
142  return peekHostApi()->ext_crypto_sr25519_public_keys_version_1(key_type);
143  }
144 
146  ext_crypto_sr25519_sign_version_1,
147  WAVM::I32 key_type,
148  WAVM::I32 key,
149  WAVM::I64 msg_data) {
150  return peekHostApi()->ext_crypto_sr25519_sign_version_1(
151  key_type, key, msg_data);
152  }
153 
155  ext_crypto_sr25519_verify_version_1,
156  WAVM::I32 sig_data,
157  WAVM::I64 msg,
158  WAVM::I32 pubkey_data) {
159  return peekHostApi()->ext_crypto_sr25519_verify_version_1(
160  sig_data, msg, pubkey_data);
161  }
162 
164  ext_crypto_sr25519_verify_version_2,
165  WAVM::I32 sig_data,
166  WAVM::I64 msg,
167  WAVM::I32 pubkey_data) {
168  return peekHostApi()->ext_crypto_sr25519_verify_version_2(
169  sig_data, msg, pubkey_data);
170  }
171 
173  ext_crypto_ecdsa_generate_version_1,
174  WAVM::I32 key_type,
175  WAVM::I64 seed) {
176  return peekHostApi()->ext_crypto_ecdsa_generate_version_1(key_type, seed);
177  }
178 
180  ext_crypto_ecdsa_public_keys_version_1,
181  WAVM::I32 key_type) {
182  return peekHostApi()->ext_crypto_ecdsa_public_keys_version_1(key_type);
183  }
184 
186  ext_crypto_ecdsa_sign_version_1,
187  WAVM::I32 key_type,
188  WAVM::I32 key,
189  WAVM::I64 msg_data) {
190  return peekHostApi()->ext_crypto_ecdsa_sign_version_1(
191  key_type, key, msg_data);
192  }
193 
195  ext_crypto_ecdsa_sign_prehashed_version_1,
196  WAVM::I32 key_type,
197  WAVM::I32 key,
198  WAVM::I64 msg_data) {
199  return peekHostApi()->ext_crypto_ecdsa_sign_prehashed_version_1(
200  key_type, key, msg_data);
201  }
202 
204  ext_crypto_ecdsa_verify_version_1,
205  WAVM::I32 sig_data,
206  WAVM::I64 msg,
207  WAVM::I32 pubkey_data) {
208  return peekHostApi()->ext_crypto_ecdsa_verify_version_1(
209  sig_data, msg, pubkey_data);
210  }
211 
213  ext_crypto_ecdsa_verify_prehashed_version_1,
214  WAVM::I32 sig_data,
215  WAVM::I64 msg,
216  WAVM::I32 pubkey_data) {
217  return peekHostApi()->ext_crypto_ecdsa_verify_prehashed_version_1(
218  sig_data, msg, pubkey_data);
219  }
220 
222  ext_crypto_start_batch_verify_version_1) {
223  return peekHostApi()->ext_crypto_start_batch_verify_version_1();
224  }
225 
227  ext_trie_blake2_256_ordered_root_version_1,
228  WAVM::I64 values_data) {
229  return peekHostApi()->ext_trie_blake2_256_ordered_root_version_1(
230  values_data);
231  }
232 
234  ext_trie_blake2_256_ordered_root_version_2,
235  WAVM::I64 values_data,
236  WAVM::I32 state_version) {
237  return peekHostApi()->ext_trie_blake2_256_ordered_root_version_2(
238  values_data, state_version);
239  }
240 
242  ext_misc_print_hex_version_1,
243  WAVM::I64 values_data) {
244  return peekHostApi()->ext_misc_print_hex_version_1(values_data);
245  }
246 
248  ext_misc_print_num_version_1,
249  WAVM::I64 values_data) {
250  return peekHostApi()->ext_misc_print_num_version_1(values_data);
251  }
252 
254  ext_misc_print_utf8_version_1,
255  WAVM::I64 values_data) {
256  return peekHostApi()->ext_misc_print_utf8_version_1(values_data);
257  }
258 
260  ext_misc_runtime_version_version_1,
261  WAVM::I64 values_data) {
262  return peekHostApi()->ext_misc_runtime_version_version_1(values_data);
263  }
264 
266  ext_default_child_storage_clear_version_1,
267  WAVM::I64 child_storage_key,
268  WAVM::I64 key) {
269  return peekHostApi()->ext_default_child_storage_clear_version_1(
270  child_storage_key, key);
271  }
272 
274  ext_default_child_storage_read_version_1,
275  WAVM::I64 child_storage_key,
276  WAVM::I64 key,
277  WAVM::I64 value_out,
278  WAVM::I32 offset) {
279  return peekHostApi()->ext_default_child_storage_read_version_1(
280  child_storage_key, key, value_out, offset);
281  }
282 
284  ext_default_child_storage_exists_version_1,
285  WAVM::I64 child_storage_key,
286  WAVM::I64 key) {
287  return peekHostApi()->ext_default_child_storage_exists_version_1(
288  child_storage_key, key);
289  }
290 
292  ext_default_child_storage_get_version_1,
293  WAVM::I64 child_storage_key,
294  WAVM::I64 key) {
295  return peekHostApi()->ext_default_child_storage_get_version_1(
296  child_storage_key, key);
297  }
298 
300  ext_default_child_storage_next_key_version_1,
301  WAVM::I64 child_storage_key,
302  WAVM::I64 key) {
303  return peekHostApi()->ext_default_child_storage_next_key_version_1(
304  child_storage_key, key);
305  }
306 
308  void,
309  ext_default_child_storage_clear_prefix_version_1,
310  WAVM::I64 child_storage_key,
311  WAVM::I64 prefix) {
312  return peekHostApi()->ext_default_child_storage_clear_prefix_version_1(
313  child_storage_key, prefix);
314  }
315 
317  ext_default_child_storage_root_version_1,
318  WAVM::I64 child_storage_key) {
319  return peekHostApi()->ext_default_child_storage_root_version_1(
320  child_storage_key);
321  }
322 
324  ext_default_child_storage_set_version_1,
325  WAVM::I64 child_storage_key,
326  WAVM::I64 key,
327  WAVM::I64 value) {
328  return peekHostApi()->ext_default_child_storage_set_version_1(
329  child_storage_key, key, value);
330  }
331 
333  void,
334  ext_default_child_storage_storage_kill_version_1,
335  WAVM::I64 child_storage_key) {
336  return peekHostApi()->ext_default_child_storage_storage_kill_version_1(
337  child_storage_key);
338  }
339 
341  ext_hashing_blake2_128_version_1,
342  WAVM::I64 data) {
343  return peekHostApi()->ext_hashing_blake2_128_version_1(data);
344  }
345 
347  ext_hashing_blake2_256_version_1,
348  WAVM::I64 data) {
349  return peekHostApi()->ext_hashing_blake2_256_version_1(data);
350  }
351 
353  ext_hashing_keccak_256_version_1,
354  WAVM::I64 data) {
355  return peekHostApi()->ext_hashing_keccak_256_version_1(data);
356  }
357 
359  ext_hashing_sha2_256_version_1,
360  WAVM::I64 data) {
361  return peekHostApi()->ext_hashing_sha2_256_version_1(data);
362  }
363 
365  ext_hashing_twox_128_version_1,
366  WAVM::I64 data) {
367  return peekHostApi()->ext_hashing_twox_128_version_1(data);
368  }
369 
371  ext_hashing_twox_64_version_1,
372  WAVM::I64 data) {
373  return peekHostApi()->ext_hashing_twox_64_version_1(data);
374  }
375 
377  ext_hashing_twox_256_version_1,
378  WAVM::I64 data) {
379  return peekHostApi()->ext_hashing_twox_256_version_1(data);
380  }
381 
382  // --------------------------- Offchain extension ----------------------------
383 
385  ext_offchain_is_validator_version_1) {
386  return peekHostApi()->ext_offchain_is_validator_version_1();
387  }
388 
390  ext_offchain_submit_transaction_version_1,
391  WAVM::I64 xt) {
392  return peekHostApi()->ext_offchain_submit_transaction_version_1(xt);
393  }
394 
396  ext_offchain_network_state_version_1) {
397  return peekHostApi()->ext_offchain_network_state_version_1();
398  }
399 
400  WAVM_DEFINE_INTRINSIC_FUNCTION(WAVM::I64, ext_offchain_timestamp_version_1) {
401  return peekHostApi()->ext_offchain_timestamp_version_1();
402  }
403 
405  ext_offchain_sleep_until_version_1,
406  WAVM::I64 deadline) {
407  return peekHostApi()->ext_offchain_sleep_until_version_1(deadline);
408  }
409 
411  ext_offchain_random_seed_version_1) {
412  return peekHostApi()->ext_offchain_random_seed_version_1();
413  }
414 
416  ext_offchain_local_storage_set_version_1,
417  WAVM::I32 kind,
418  WAVM::I64 key,
419  WAVM::I64 value) {
420  return peekHostApi()->ext_offchain_local_storage_set_version_1(
421  kind, key, value);
422  }
423 
425  ext_offchain_local_storage_clear_version_1,
426  WAVM::I32 kind,
427  WAVM::I64 key) {
428  return peekHostApi()->ext_offchain_local_storage_clear_version_1(kind, key);
429  }
430 
432  WAVM::I32,
433  ext_offchain_local_storage_compare_and_set_version_1,
434  WAVM::I32 kind,
435  WAVM::I64 key,
436  WAVM::I64 expected,
437  WAVM::I64 value) {
438  return peekHostApi()->ext_offchain_local_storage_compare_and_set_version_1(
439  kind, key, expected, value);
440  }
441 
443  ext_offchain_local_storage_get_version_1,
444  WAVM::I32 kind,
445  WAVM::I64 key) {
446  return peekHostApi()->ext_offchain_local_storage_get_version_1(kind, key);
447  }
448 
450  ext_offchain_http_request_start_version_1,
451  WAVM::I64 method,
452  WAVM::I64 uri,
453  WAVM::I64 meta) {
454  return peekHostApi()->ext_offchain_http_request_start_version_1(
455  method, uri, meta);
456  }
457 
459  ext_offchain_http_request_add_header_version_1,
460  WAVM::I32 request_id,
461  WAVM::I64 name,
462  WAVM::I64 value) {
463  return peekHostApi()->ext_offchain_http_request_add_header_version_1(
464  request_id, name, value);
465  }
466 
468  ext_offchain_http_request_write_body_version_1,
469  WAVM::I32 request_id,
470  WAVM::I64 chunk,
471  WAVM::I64 deadline) {
472  return peekHostApi()->ext_offchain_http_request_write_body_version_1(
473  request_id, chunk, deadline);
474  }
475 
477  ext_offchain_http_response_wait_version_1,
478  WAVM::I64 ids,
479  WAVM::I64 deadline) {
480  return peekHostApi()->ext_offchain_http_response_wait_version_1(ids,
481  deadline);
482  }
483 
485  ext_offchain_http_response_headers_version_1,
486  WAVM::I32 request_id) {
487  return peekHostApi()->ext_offchain_http_response_headers_version_1(
488  request_id);
489  }
490 
492  ext_offchain_http_response_read_body_version_1,
493  WAVM::I32 request_id,
494  WAVM::I64 buffer,
495  WAVM::I64 deadline) {
496  return peekHostApi()->ext_offchain_http_response_read_body_version_1(
497  request_id, buffer, deadline);
498  }
499 
501  ext_offchain_set_authorized_nodes_version_1,
502  WAVM::I64 nodes,
503  WAVM::I32 authorized_only) {
504  return peekHostApi()->ext_offchain_set_authorized_nodes_version_1(
505  nodes, authorized_only);
506  }
507 
509  ext_offchain_index_set_version_1,
510  WAVM::I64 key,
511  WAVM::I64 value) {
512  return peekHostApi()->ext_offchain_index_set_version_1(key, value);
513  }
514 
516  ext_offchain_index_clear_version_1,
517  WAVM::I64 key) {
518  return peekHostApi()->ext_offchain_index_clear_version_1(key);
519  }
520 
521  // ---------------------------------------------------------------------------
522 
524  ext_storage_append_version_1,
525  WAVM::I64 key,
526  WAVM::I64 value) {
527  return peekHostApi()->ext_storage_append_version_1(key, value);
528  }
529 
531  ext_storage_changes_root_version_1,
532  WAVM::I64 parent_hash) {
533  return peekHostApi()->ext_storage_changes_root_version_1(parent_hash);
534  }
535 
537  ext_storage_clear_version_1,
538  WAVM::I64 key_data) {
539  return peekHostApi()->ext_storage_clear_version_1(key_data);
540  }
541 
543  ext_storage_clear_prefix_version_1,
544  WAVM::I64 prefix) {
545  return peekHostApi()->ext_storage_clear_prefix_version_1(prefix);
546  }
547 
549  ext_storage_clear_prefix_version_2,
550  WAVM::I64 prefix,
551  WAVM::I64 limit) {
552  return peekHostApi()->ext_storage_clear_prefix_version_2(prefix, limit);
553  }
554 
556  ext_storage_commit_transaction_version_1) {
557  return peekHostApi()->ext_storage_commit_transaction_version_1();
558  }
559 
561  ext_storage_get_version_1,
562  WAVM::I64 key) {
563  return peekHostApi()->ext_storage_get_version_1(key);
564  }
565 
567  ext_storage_next_key_version_1,
568  WAVM::I64 key) {
569  return peekHostApi()->ext_storage_next_key_version_1(key);
570  }
571 
573  ext_storage_read_version_1,
574  WAVM::I64 key,
575  WAVM::I64 value_out,
576  WAVM::I32 offset) {
577  return peekHostApi()->ext_storage_read_version_1(key, value_out, offset);
578  }
579 
581  ext_storage_rollback_transaction_version_1) {
582  return peekHostApi()->ext_storage_rollback_transaction_version_1();
583  }
584 
585  WAVM_DEFINE_INTRINSIC_FUNCTION(WAVM::I64, ext_storage_root_version_1) {
586  return peekHostApi()->ext_storage_root_version_1();
587  }
588 
590  ext_storage_root_version_2,
591  WAVM::I32 state_version) {
592  return peekHostApi()->ext_storage_root_version_2(state_version);
593  }
594 
596  ext_storage_set_version_1,
597  WAVM::I64 key,
598  WAVM::I64 value) {
599  return peekHostApi()->ext_storage_set_version_1(key, value);
600  }
601 
603  ext_storage_start_transaction_version_1) {
604  return peekHostApi()->ext_storage_start_transaction_version_1();
605  }
606 
608  ext_storage_exists_version_1,
609  WAVM::I64 key) {
610  return peekHostApi()->ext_storage_exists_version_1(key);
611  }
612 
614  ext_logging_log_version_1,
615  WAVM::I32 level,
616  WAVM::I64 target,
617  WAVM::I64 message) {
618  return peekHostApi()->ext_logging_log_version_1(level, target, message);
619  }
620 
621  WAVM_DEFINE_INTRINSIC_FUNCTION(WAVM::I32, ext_logging_max_level_version_1) {
622  return peekHostApi()->ext_logging_max_level_version_1();
623  }
624 
626  ext_sandbox_instance_teardown_version_1,
627  WAVM::I32)
628 
630  ext_sandbox_instantiate_version_1,
631  WAVM::I32,
632  WAVM::I64,
633  WAVM::I64,
634  WAVM::I32)
635 
637  ext_sandbox_invoke_version_1,
638  WAVM::I32,
639  WAVM::I64,
640  WAVM::I64,
641  WAVM::I32,
642  WAVM::I32,
643  WAVM::I32)
644 
646  ext_sandbox_memory_get_version_1,
647  WAVM::I32,
648  WAVM::I32,
649  WAVM::I32,
650  WAVM::I32)
651 
653  ext_sandbox_memory_new_version_1,
654  WAVM::I32,
655  WAVM::I32)
656 
658  ext_sandbox_memory_set_version_1,
659  WAVM::I32,
660  WAVM::I32,
661  WAVM::I32,
662  WAVM::I32)
663 
665  ext_sandbox_memory_teardown_version_1,
666  WAVM::I32)
667 
669  ext_trie_blake2_256_root_version_1,
670  WAVM::I64 values_data) {
671  return peekHostApi()->ext_trie_blake2_256_root_version_1(values_data);
672  }
673 
675  if (logger == nullptr)
676  logger = log::createLogger("Host API wrappers", "wavm");
677 
678 #define REGISTER_HOST_INTRINSIC(Ret, name, ...) \
679  module.addFunction( \
680  #name, &name, WAVM::IR::FunctionType{{Ret}, {__VA_ARGS__}});
681 
682  auto I32 = WAVM::IR::ValueType::i32;
683  auto I64 = WAVM::IR::ValueType::i64;
684  // clang-format off
685  REGISTER_HOST_INTRINSIC(, ext_allocator_free_version_1, I32)
686  REGISTER_HOST_INTRINSIC(, ext_crypto_start_batch_verify_version_1)
687  REGISTER_HOST_INTRINSIC(, ext_default_child_storage_clear_version_1, I64, I64)
688  REGISTER_HOST_INTRINSIC(, ext_default_child_storage_clear_prefix_version_1, I64, I64)
689  REGISTER_HOST_INTRINSIC(, ext_default_child_storage_set_version_1, I64, I64, I64)
690  REGISTER_HOST_INTRINSIC(, ext_default_child_storage_storage_kill_version_1, I64)
691  REGISTER_HOST_INTRINSIC(, ext_logging_log_version_1, I32, I64, I64)
692  REGISTER_HOST_INTRINSIC(, ext_misc_print_hex_version_1, I64)
693  REGISTER_HOST_INTRINSIC(, ext_misc_print_num_version_1, I64)
694  REGISTER_HOST_INTRINSIC(, ext_misc_print_utf8_version_1, I64)
695  REGISTER_HOST_INTRINSIC(, ext_sandbox_instance_teardown_version_1, I32)
696  REGISTER_HOST_INTRINSIC(, ext_sandbox_memory_teardown_version_1, I32)
697  REGISTER_HOST_INTRINSIC(, ext_storage_append_version_1, I64, I64)
698  REGISTER_HOST_INTRINSIC(, ext_storage_clear_prefix_version_1, I64)
699  REGISTER_HOST_INTRINSIC(, ext_storage_clear_version_1, I64)
700  REGISTER_HOST_INTRINSIC(, ext_storage_commit_transaction_version_1)
701  REGISTER_HOST_INTRINSIC(, ext_storage_rollback_transaction_version_1)
702  REGISTER_HOST_INTRINSIC(, ext_storage_set_version_1, I64, I64)
703  REGISTER_HOST_INTRINSIC(, ext_storage_start_transaction_version_1)
704  REGISTER_HOST_INTRINSIC(I32, ext_allocator_malloc_version_1, I32)
705  REGISTER_HOST_INTRINSIC(I32, ext_crypto_ed25519_generate_version_1, I32, I64)
706  REGISTER_HOST_INTRINSIC(I32, ext_crypto_ed25519_verify_version_1, I32, I64, I32)
707  REGISTER_HOST_INTRINSIC(I32, ext_crypto_finish_batch_verify_version_1)
708  REGISTER_HOST_INTRINSIC(I32, ext_crypto_sr25519_generate_version_1, I32, I64)
709  REGISTER_HOST_INTRINSIC(I32, ext_crypto_sr25519_verify_version_1, I32, I64, I32)
710  REGISTER_HOST_INTRINSIC(I32, ext_crypto_sr25519_verify_version_2, I32, I64, I32)
711  REGISTER_HOST_INTRINSIC(I64, ext_crypto_ecdsa_public_keys_version_1, I32)
712  REGISTER_HOST_INTRINSIC(I64, ext_crypto_ecdsa_sign_version_1, I32, I32, I64)
713  REGISTER_HOST_INTRINSIC(I64, ext_crypto_ecdsa_sign_prehashed_version_1, I32, I32, I64)
714  REGISTER_HOST_INTRINSIC(I32, ext_crypto_ecdsa_generate_version_1, I32, I64)
715  REGISTER_HOST_INTRINSIC(I32, ext_crypto_ecdsa_verify_version_1, I32, I64, I32)
716  REGISTER_HOST_INTRINSIC(I32, ext_crypto_ecdsa_verify_prehashed_version_1, I32, I64, I32)
717  REGISTER_HOST_INTRINSIC(I32, ext_default_child_storage_exists_version_1, I64, I64)
718  REGISTER_HOST_INTRINSIC(I32, ext_hashing_blake2_128_version_1, I64)
719  REGISTER_HOST_INTRINSIC(I32, ext_hashing_blake2_256_version_1, I64)
720  REGISTER_HOST_INTRINSIC(I32, ext_hashing_keccak_256_version_1, I64)
721  REGISTER_HOST_INTRINSIC(I32, ext_hashing_sha2_256_version_1, I64)
722  REGISTER_HOST_INTRINSIC(I32, ext_hashing_twox_64_version_1, I64)
723  REGISTER_HOST_INTRINSIC(I32, ext_hashing_twox_128_version_1, I64)
724  REGISTER_HOST_INTRINSIC(I32, ext_hashing_twox_256_version_1, I64)
725  REGISTER_HOST_INTRINSIC(I32, ext_logging_max_level_version_1)
726  REGISTER_HOST_INTRINSIC(I32, ext_sandbox_instantiate_version_1, I32, I64, I64, I32)
727  REGISTER_HOST_INTRINSIC(I32, ext_sandbox_invoke_version_1, I32, I64, I64, I32, I32, I32)
728  REGISTER_HOST_INTRINSIC(I32, ext_sandbox_memory_get_version_1, I32, I32, I32, I32)
729  REGISTER_HOST_INTRINSIC(I32, ext_sandbox_memory_new_version_1, I32, I32)
730  REGISTER_HOST_INTRINSIC(I32, ext_sandbox_memory_set_version_1, I32, I32, I32, I32)
731  REGISTER_HOST_INTRINSIC(I32, ext_storage_exists_version_1, I64)
732  REGISTER_HOST_INTRINSIC(I32, ext_trie_blake2_256_ordered_root_version_1, I64)
733  REGISTER_HOST_INTRINSIC(I32, ext_trie_blake2_256_ordered_root_version_2, I64, I32)
734  REGISTER_HOST_INTRINSIC(I32, ext_trie_blake2_256_root_version_1, I64)
735  REGISTER_HOST_INTRINSIC(I64, ext_crypto_ed25519_public_keys_version_1, I32)
736  REGISTER_HOST_INTRINSIC(I64, ext_crypto_ed25519_sign_version_1, I32, I32, I64)
737  REGISTER_HOST_INTRINSIC(I64, ext_crypto_secp256k1_ecdsa_recover_compressed_version_1, I32, I32)
738  REGISTER_HOST_INTRINSIC(I64, ext_crypto_secp256k1_ecdsa_recover_compressed_version_2, I32, I32)
739  REGISTER_HOST_INTRINSIC(I64, ext_crypto_secp256k1_ecdsa_recover_version_1, I32, I32)
740  REGISTER_HOST_INTRINSIC(I64, ext_crypto_secp256k1_ecdsa_recover_version_2, I32, I32)
741  REGISTER_HOST_INTRINSIC(I64, ext_crypto_sr25519_public_keys_version_1, I32)
742  REGISTER_HOST_INTRINSIC(I64, ext_crypto_sr25519_sign_version_1, I32, I32, I64)
743  REGISTER_HOST_INTRINSIC(I64, ext_default_child_storage_get_version_1, I64, I64)
744  REGISTER_HOST_INTRINSIC(I64, ext_default_child_storage_next_key_version_1, I64, I64)
745  REGISTER_HOST_INTRINSIC(I64, ext_default_child_storage_read_version_1, I64, I64, I64, I32)
746  REGISTER_HOST_INTRINSIC(I64, ext_default_child_storage_root_version_1, I64)
747  REGISTER_HOST_INTRINSIC(I64, ext_misc_runtime_version_version_1, I64)
748  REGISTER_HOST_INTRINSIC(I64, ext_storage_changes_root_version_1, I64)
749  REGISTER_HOST_INTRINSIC(I64, ext_storage_clear_prefix_version_2, I64, I64)
750  REGISTER_HOST_INTRINSIC(I64, ext_storage_get_version_1, I64)
751  REGISTER_HOST_INTRINSIC(I64, ext_storage_next_key_version_1, I64)
752  REGISTER_HOST_INTRINSIC(I64, ext_storage_read_version_1, I64, I64, I32)
753  REGISTER_HOST_INTRINSIC(I64, ext_storage_root_version_1)
754  REGISTER_HOST_INTRINSIC(I64, ext_storage_root_version_2, I32)
755 
756  // -------------------------- Offchain extension ---------------------------
757  REGISTER_HOST_INTRINSIC(I32, ext_offchain_is_validator_version_1)
758  REGISTER_HOST_INTRINSIC(I64, ext_offchain_submit_transaction_version_1, I64)
759  REGISTER_HOST_INTRINSIC(I64, ext_offchain_network_state_version_1)
760  REGISTER_HOST_INTRINSIC(I64, ext_offchain_timestamp_version_1)
761  REGISTER_HOST_INTRINSIC( , ext_offchain_sleep_until_version_1, I64)
762  REGISTER_HOST_INTRINSIC(I32, ext_offchain_random_seed_version_1)
763  REGISTER_HOST_INTRINSIC( , ext_offchain_local_storage_set_version_1, I32, I64, I64)
764  REGISTER_HOST_INTRINSIC( , ext_offchain_local_storage_clear_version_1, I32, I64)
765  REGISTER_HOST_INTRINSIC(I32, ext_offchain_local_storage_compare_and_set_version_1, I32, I64, I64, I64)
766  REGISTER_HOST_INTRINSIC(I64, ext_offchain_local_storage_get_version_1, I32, I64)
767  REGISTER_HOST_INTRINSIC(I64, ext_offchain_http_request_start_version_1, I64, I64, I64)
768  REGISTER_HOST_INTRINSIC(I64, ext_offchain_http_request_add_header_version_1, I32, I64, I64)
769  REGISTER_HOST_INTRINSIC(I64, ext_offchain_http_request_write_body_version_1, I32,I64,I64)
770  REGISTER_HOST_INTRINSIC(I64, ext_offchain_http_response_wait_version_1,I64,I64)
771  REGISTER_HOST_INTRINSIC(I64, ext_offchain_http_response_headers_version_1, I32)
772  REGISTER_HOST_INTRINSIC(I64, ext_offchain_http_response_read_body_version_1, I32, I64, I64)
773  REGISTER_HOST_INTRINSIC( , ext_offchain_set_authorized_nodes_version_1, I64, I32)
774  REGISTER_HOST_INTRINSIC( , ext_offchain_index_set_version_1, I64, I64)
775  REGISTER_HOST_INTRINSIC( , ext_offchain_index_clear_version_1, I64)
776 
777  // clang-format on
778  }
779 
780 } // namespace kagome::runtime::wavm
WAVM_DEFINE_INTRINSIC_FUNCTION(void, ext_allocator_free_version_1, WAVM::I32 address)
#define REGISTER_HOST_INTRINSIC(Ret, name,...)
static thread_local std::stack< std::shared_ptr< ModuleInstance > > global_instances
std::shared_ptr< ModuleInstance > peekBorrowedRuntimeInstance()
std::shared_ptr< soralog::Logger > Logger
Definition: logger.hpp:23
std::shared_ptr< host_api::HostApi > peekHostApi()
WAVM_DEFINE_INTRINSIC_FUNCTION_STUB(void, ext_sandbox_instance_teardown_version_1, WAVM::I32) WAVM_DEFINE_INTRINSIC_FUNCTION_STUB(WAVM
Logger createLogger(const std::string &tag)
Definition: logger.cpp:112
void registerHostApiMethods(IntrinsicModule &module)
void pushBorrowedRuntimeInstance(std::shared_ptr< ModuleInstance > borrowed_runtime_instance)