Kagome
Polkadot Runtime Engine in C++17
intrinsic_functions.cpp File Reference
Include dependency graph for intrinsic_functions.cpp:

Go to the source code of this file.

Namespaces

 kagome::runtime::wavm
 

Macros

#define WAVM_DEFINE_INTRINSIC_FUNCTION(Result, cName, ...)
 
#define WAVM_DEFINE_INTRINSIC_FUNCTION_STUB(Result, cName, ...)
 
#define REGISTER_HOST_INTRINSIC(Ret, name, ...)
 

Functions

void kagome::runtime::wavm::pushBorrowedRuntimeInstance (std::shared_ptr< ModuleInstance > borrowed_runtime_instance)
 
void kagome::runtime::wavm::popBorrowedRuntimeInstance ()
 
std::shared_ptr< ModuleInstance > kagome::runtime::wavm::peekBorrowedRuntimeInstance ()
 
std::shared_ptr< host_api::HostApi > kagome::runtime::wavm::peekHostApi ()
 
 kagome::runtime::wavm::WAVM_DEFINE_INTRINSIC_FUNCTION (void, ext_allocator_free_version_1, WAVM::I32 address)
 
 kagome::runtime::wavm::WAVM_DEFINE_INTRINSIC_FUNCTION (WAVM::I32, ext_allocator_malloc_version_1, WAVM::I32 size)
 
 kagome::runtime::wavm::WAVM_DEFINE_INTRINSIC_FUNCTION (WAVM::I32, ext_crypto_ed25519_generate_version_1, WAVM::I32 keytype, WAVM::I64 seed)
 
 kagome::runtime::wavm::WAVM_DEFINE_INTRINSIC_FUNCTION (WAVM::I64, ext_crypto_ed25519_public_keys_version_1, WAVM::I32 key_type)
 
 kagome::runtime::wavm::WAVM_DEFINE_INTRINSIC_FUNCTION (WAVM::I64, ext_crypto_ed25519_sign_version_1, WAVM::I32 key_type, WAVM::I32 key, WAVM::I64 msg_data)
 
 kagome::runtime::wavm::WAVM_DEFINE_INTRINSIC_FUNCTION (WAVM::I32, ext_crypto_ed25519_verify_version_1, WAVM::I32 sig_data, WAVM::I64 msg, WAVM::I32 pubkey_data)
 
 kagome::runtime::wavm::WAVM_DEFINE_INTRINSIC_FUNCTION (WAVM::I32, ext_crypto_finish_batch_verify_version_1)
 
 kagome::runtime::wavm::WAVM_DEFINE_INTRINSIC_FUNCTION (WAVM::I64, ext_crypto_secp256k1_ecdsa_recover_version_1, WAVM::I32 sig, WAVM::I32 msg)
 
 kagome::runtime::wavm::WAVM_DEFINE_INTRINSIC_FUNCTION (WAVM::I64, ext_crypto_secp256k1_ecdsa_recover_version_2, WAVM::I32 sig, WAVM::I32 msg)
 
 kagome::runtime::wavm::WAVM_DEFINE_INTRINSIC_FUNCTION (WAVM::I64, ext_crypto_secp256k1_ecdsa_recover_compressed_version_1, WAVM::I32 sig, WAVM::I32 msg)
 
 kagome::runtime::wavm::WAVM_DEFINE_INTRINSIC_FUNCTION (WAVM::I64, ext_crypto_secp256k1_ecdsa_recover_compressed_version_2, WAVM::I32 sig, WAVM::I32 msg)
 
 kagome::runtime::wavm::WAVM_DEFINE_INTRINSIC_FUNCTION (WAVM::I32, ext_crypto_sr25519_generate_version_1, WAVM::I32 key_type, WAVM::I64 seed)
 
 kagome::runtime::wavm::WAVM_DEFINE_INTRINSIC_FUNCTION (WAVM::I64, ext_crypto_sr25519_public_keys_version_1, WAVM::I32 key_type)
 
 kagome::runtime::wavm::WAVM_DEFINE_INTRINSIC_FUNCTION (WAVM::I64, ext_crypto_sr25519_sign_version_1, WAVM::I32 key_type, WAVM::I32 key, WAVM::I64 msg_data)
 
 kagome::runtime::wavm::WAVM_DEFINE_INTRINSIC_FUNCTION (WAVM::I32, ext_crypto_sr25519_verify_version_1, WAVM::I32 sig_data, WAVM::I64 msg, WAVM::I32 pubkey_data)
 
 kagome::runtime::wavm::WAVM_DEFINE_INTRINSIC_FUNCTION (WAVM::I32, ext_crypto_sr25519_verify_version_2, WAVM::I32 sig_data, WAVM::I64 msg, WAVM::I32 pubkey_data)
 
 kagome::runtime::wavm::WAVM_DEFINE_INTRINSIC_FUNCTION (WAVM::I32, ext_crypto_ecdsa_generate_version_1, WAVM::I32 key_type, WAVM::I64 seed)
 
 kagome::runtime::wavm::WAVM_DEFINE_INTRINSIC_FUNCTION (WAVM::I64, ext_crypto_ecdsa_public_keys_version_1, WAVM::I32 key_type)
 
 kagome::runtime::wavm::WAVM_DEFINE_INTRINSIC_FUNCTION (WAVM::I64, ext_crypto_ecdsa_sign_version_1, WAVM::I32 key_type, WAVM::I32 key, WAVM::I64 msg_data)
 
 kagome::runtime::wavm::WAVM_DEFINE_INTRINSIC_FUNCTION (WAVM::I64, ext_crypto_ecdsa_sign_prehashed_version_1, WAVM::I32 key_type, WAVM::I32 key, WAVM::I64 msg_data)
 
 kagome::runtime::wavm::WAVM_DEFINE_INTRINSIC_FUNCTION (WAVM::I32, ext_crypto_ecdsa_verify_version_1, WAVM::I32 sig_data, WAVM::I64 msg, WAVM::I32 pubkey_data)
 
 kagome::runtime::wavm::WAVM_DEFINE_INTRINSIC_FUNCTION (WAVM::I32, ext_crypto_ecdsa_verify_prehashed_version_1, WAVM::I32 sig_data, WAVM::I64 msg, WAVM::I32 pubkey_data)
 
 kagome::runtime::wavm::WAVM_DEFINE_INTRINSIC_FUNCTION (void, ext_crypto_start_batch_verify_version_1)
 
 kagome::runtime::wavm::WAVM_DEFINE_INTRINSIC_FUNCTION (WAVM::I32, ext_trie_blake2_256_ordered_root_version_1, WAVM::I64 values_data)
 
 kagome::runtime::wavm::WAVM_DEFINE_INTRINSIC_FUNCTION (WAVM::I32, ext_trie_blake2_256_ordered_root_version_2, WAVM::I64 values_data, WAVM::I32 state_version)
 
 kagome::runtime::wavm::WAVM_DEFINE_INTRINSIC_FUNCTION (void, ext_misc_print_hex_version_1, WAVM::I64 values_data)
 
 kagome::runtime::wavm::WAVM_DEFINE_INTRINSIC_FUNCTION (void, ext_misc_print_num_version_1, WAVM::I64 values_data)
 
 kagome::runtime::wavm::WAVM_DEFINE_INTRINSIC_FUNCTION (void, ext_misc_print_utf8_version_1, WAVM::I64 values_data)
 
 kagome::runtime::wavm::WAVM_DEFINE_INTRINSIC_FUNCTION (WAVM::I64, ext_misc_runtime_version_version_1, WAVM::I64 values_data)
 
 kagome::runtime::wavm::WAVM_DEFINE_INTRINSIC_FUNCTION (void, ext_default_child_storage_clear_version_1, WAVM::I64 child_storage_key, WAVM::I64 key)
 
 kagome::runtime::wavm::WAVM_DEFINE_INTRINSIC_FUNCTION (WAVM::I64, ext_default_child_storage_read_version_1, WAVM::I64 child_storage_key, WAVM::I64 key, WAVM::I64 value_out, WAVM::I32 offset)
 
 kagome::runtime::wavm::WAVM_DEFINE_INTRINSIC_FUNCTION (WAVM::I32, ext_default_child_storage_exists_version_1, WAVM::I64 child_storage_key, WAVM::I64 key)
 
 kagome::runtime::wavm::WAVM_DEFINE_INTRINSIC_FUNCTION (WAVM::I64, ext_default_child_storage_get_version_1, WAVM::I64 child_storage_key, WAVM::I64 key)
 
 kagome::runtime::wavm::WAVM_DEFINE_INTRINSIC_FUNCTION (WAVM::I64, ext_default_child_storage_next_key_version_1, WAVM::I64 child_storage_key, WAVM::I64 key)
 
 kagome::runtime::wavm::WAVM_DEFINE_INTRINSIC_FUNCTION (void, ext_default_child_storage_clear_prefix_version_1, WAVM::I64 child_storage_key, WAVM::I64 prefix)
 
 kagome::runtime::wavm::WAVM_DEFINE_INTRINSIC_FUNCTION (WAVM::I64, ext_default_child_storage_root_version_1, WAVM::I64 child_storage_key)
 
 kagome::runtime::wavm::WAVM_DEFINE_INTRINSIC_FUNCTION (void, ext_default_child_storage_set_version_1, WAVM::I64 child_storage_key, WAVM::I64 key, WAVM::I64 value)
 
 kagome::runtime::wavm::WAVM_DEFINE_INTRINSIC_FUNCTION (void, ext_default_child_storage_storage_kill_version_1, WAVM::I64 child_storage_key)
 
 kagome::runtime::wavm::WAVM_DEFINE_INTRINSIC_FUNCTION (WAVM::I32, ext_hashing_blake2_128_version_1, WAVM::I64 data)
 
 kagome::runtime::wavm::WAVM_DEFINE_INTRINSIC_FUNCTION (WAVM::I32, ext_hashing_blake2_256_version_1, WAVM::I64 data)
 
 kagome::runtime::wavm::WAVM_DEFINE_INTRINSIC_FUNCTION (WAVM::I32, ext_hashing_keccak_256_version_1, WAVM::I64 data)
 
 kagome::runtime::wavm::WAVM_DEFINE_INTRINSIC_FUNCTION (WAVM::I32, ext_hashing_sha2_256_version_1, WAVM::I64 data)
 
 kagome::runtime::wavm::WAVM_DEFINE_INTRINSIC_FUNCTION (WAVM::I32, ext_hashing_twox_128_version_1, WAVM::I64 data)
 
 kagome::runtime::wavm::WAVM_DEFINE_INTRINSIC_FUNCTION (WAVM::I32, ext_hashing_twox_64_version_1, WAVM::I64 data)
 
 kagome::runtime::wavm::WAVM_DEFINE_INTRINSIC_FUNCTION (WAVM::I32, ext_hashing_twox_256_version_1, WAVM::I64 data)
 
 kagome::runtime::wavm::WAVM_DEFINE_INTRINSIC_FUNCTION (WAVM::I32, ext_offchain_is_validator_version_1)
 
 kagome::runtime::wavm::WAVM_DEFINE_INTRINSIC_FUNCTION (WAVM::I64, ext_offchain_submit_transaction_version_1, WAVM::I64 xt)
 
 kagome::runtime::wavm::WAVM_DEFINE_INTRINSIC_FUNCTION (WAVM::I64, ext_offchain_network_state_version_1)
 
 kagome::runtime::wavm::WAVM_DEFINE_INTRINSIC_FUNCTION (WAVM::I64, ext_offchain_timestamp_version_1)
 
 kagome::runtime::wavm::WAVM_DEFINE_INTRINSIC_FUNCTION (void, ext_offchain_sleep_until_version_1, WAVM::I64 deadline)
 
 kagome::runtime::wavm::WAVM_DEFINE_INTRINSIC_FUNCTION (WAVM::I32, ext_offchain_random_seed_version_1)
 
 kagome::runtime::wavm::WAVM_DEFINE_INTRINSIC_FUNCTION (void, ext_offchain_local_storage_set_version_1, WAVM::I32 kind, WAVM::I64 key, WAVM::I64 value)
 
 kagome::runtime::wavm::WAVM_DEFINE_INTRINSIC_FUNCTION (void, ext_offchain_local_storage_clear_version_1, WAVM::I32 kind, WAVM::I64 key)
 
 kagome::runtime::wavm::WAVM_DEFINE_INTRINSIC_FUNCTION (WAVM::I32, ext_offchain_local_storage_compare_and_set_version_1, WAVM::I32 kind, WAVM::I64 key, WAVM::I64 expected, WAVM::I64 value)
 
 kagome::runtime::wavm::WAVM_DEFINE_INTRINSIC_FUNCTION (WAVM::I64, ext_offchain_local_storage_get_version_1, WAVM::I32 kind, WAVM::I64 key)
 
 kagome::runtime::wavm::WAVM_DEFINE_INTRINSIC_FUNCTION (WAVM::I64, ext_offchain_http_request_start_version_1, WAVM::I64 method, WAVM::I64 uri, WAVM::I64 meta)
 
 kagome::runtime::wavm::WAVM_DEFINE_INTRINSIC_FUNCTION (WAVM::I64, ext_offchain_http_request_add_header_version_1, WAVM::I32 request_id, WAVM::I64 name, WAVM::I64 value)
 
 kagome::runtime::wavm::WAVM_DEFINE_INTRINSIC_FUNCTION (WAVM::I64, ext_offchain_http_request_write_body_version_1, WAVM::I32 request_id, WAVM::I64 chunk, WAVM::I64 deadline)
 
 kagome::runtime::wavm::WAVM_DEFINE_INTRINSIC_FUNCTION (WAVM::I64, ext_offchain_http_response_wait_version_1, WAVM::I64 ids, WAVM::I64 deadline)
 
 kagome::runtime::wavm::WAVM_DEFINE_INTRINSIC_FUNCTION (WAVM::I64, ext_offchain_http_response_headers_version_1, WAVM::I32 request_id)
 
 kagome::runtime::wavm::WAVM_DEFINE_INTRINSIC_FUNCTION (WAVM::I64, ext_offchain_http_response_read_body_version_1, WAVM::I32 request_id, WAVM::I64 buffer, WAVM::I64 deadline)
 
 kagome::runtime::wavm::WAVM_DEFINE_INTRINSIC_FUNCTION (void, ext_offchain_set_authorized_nodes_version_1, WAVM::I64 nodes, WAVM::I32 authorized_only)
 
 kagome::runtime::wavm::WAVM_DEFINE_INTRINSIC_FUNCTION (void, ext_offchain_index_set_version_1, WAVM::I64 key, WAVM::I64 value)
 
 kagome::runtime::wavm::WAVM_DEFINE_INTRINSIC_FUNCTION (void, ext_offchain_index_clear_version_1, WAVM::I64 key)
 
 kagome::runtime::wavm::WAVM_DEFINE_INTRINSIC_FUNCTION (void, ext_storage_append_version_1, WAVM::I64 key, WAVM::I64 value)
 
 kagome::runtime::wavm::WAVM_DEFINE_INTRINSIC_FUNCTION (WAVM::I64, ext_storage_changes_root_version_1, WAVM::I64 parent_hash)
 
 kagome::runtime::wavm::WAVM_DEFINE_INTRINSIC_FUNCTION (void, ext_storage_clear_version_1, WAVM::I64 key_data)
 
 kagome::runtime::wavm::WAVM_DEFINE_INTRINSIC_FUNCTION (void, ext_storage_clear_prefix_version_1, WAVM::I64 prefix)
 
 kagome::runtime::wavm::WAVM_DEFINE_INTRINSIC_FUNCTION (WAVM::I64, ext_storage_clear_prefix_version_2, WAVM::I64 prefix, WAVM::I64 limit)
 
 kagome::runtime::wavm::WAVM_DEFINE_INTRINSIC_FUNCTION (void, ext_storage_commit_transaction_version_1)
 
 kagome::runtime::wavm::WAVM_DEFINE_INTRINSIC_FUNCTION (WAVM::I64, ext_storage_get_version_1, WAVM::I64 key)
 
 kagome::runtime::wavm::WAVM_DEFINE_INTRINSIC_FUNCTION (WAVM::I64, ext_storage_next_key_version_1, WAVM::I64 key)
 
 kagome::runtime::wavm::WAVM_DEFINE_INTRINSIC_FUNCTION (WAVM::I64, ext_storage_read_version_1, WAVM::I64 key, WAVM::I64 value_out, WAVM::I32 offset)
 
 kagome::runtime::wavm::WAVM_DEFINE_INTRINSIC_FUNCTION (void, ext_storage_rollback_transaction_version_1)
 
 kagome::runtime::wavm::WAVM_DEFINE_INTRINSIC_FUNCTION (WAVM::I64, ext_storage_root_version_1)
 
 kagome::runtime::wavm::WAVM_DEFINE_INTRINSIC_FUNCTION (WAVM::I64, ext_storage_root_version_2, WAVM::I32 state_version)
 
 kagome::runtime::wavm::WAVM_DEFINE_INTRINSIC_FUNCTION (void, ext_storage_set_version_1, WAVM::I64 key, WAVM::I64 value)
 
 kagome::runtime::wavm::WAVM_DEFINE_INTRINSIC_FUNCTION (void, ext_storage_start_transaction_version_1)
 
 kagome::runtime::wavm::WAVM_DEFINE_INTRINSIC_FUNCTION (WAVM::I32, ext_storage_exists_version_1, WAVM::I64 key)
 
 kagome::runtime::wavm::WAVM_DEFINE_INTRINSIC_FUNCTION (void, ext_logging_log_version_1, WAVM::I32 level, WAVM::I64 target, WAVM::I64 message)
 
 kagome::runtime::wavm::WAVM_DEFINE_INTRINSIC_FUNCTION (WAVM::I32, ext_logging_max_level_version_1)
 
 kagome::runtime::wavm::WAVM_DEFINE_INTRINSIC_FUNCTION_STUB (void, ext_sandbox_instance_teardown_version_1, WAVM::I32) WAVM_DEFINE_INTRINSIC_FUNCTION_STUB(WAVM
 
void kagome::runtime::wavm::registerHostApiMethods (IntrinsicModule &module)
 

Variables

log::Logger kagome::runtime::wavm::logger
 
static thread_local std::stack< std::shared_ptr< ModuleInstance > > kagome::runtime::wavm::global_instances
 

Macro Definition Documentation

#define REGISTER_HOST_INTRINSIC (   Ret,
  name,
  ... 
)
Value:
module.addFunction( \
#name, &name, WAVM::IR::FunctionType{{Ret}, {__VA_ARGS__}});
#define WAVM_DEFINE_INTRINSIC_FUNCTION (   Result,
  cName,
  ... 
)
Value:
Result cName(WAVM::Runtime::ContextRuntimeData *contextRuntimeData, \
##__VA_ARGS__)

Definition at line 39 of file intrinsic_functions.cpp.

#define WAVM_DEFINE_INTRINSIC_FUNCTION_STUB (   Result,
  cName,
  ... 
)
Value:
Result cName(WAVM::Runtime::ContextRuntimeData *contextRuntimeData, \
##__VA_ARGS__) { \
logger->warn("Unimplemented Host API function " #cName " was called"); \
return Result(); \
}

Definition at line 43 of file intrinsic_functions.cpp.