Kagome
Polkadot Runtime Engine in C++17
|
#include <host_api_impl.hpp>
Public Member Functions | |
HostApiImpl ()=delete | |
HostApiImpl (const OffchainExtensionConfig &offchain_config, std::shared_ptr< const runtime::MemoryProvider > memory_provider, std::shared_ptr< const runtime::CoreApiFactory > core_provider, std::shared_ptr< runtime::TrieStorageProvider > storage_provider, std::shared_ptr< const crypto::Sr25519Provider > sr25519_provider, std::shared_ptr< const crypto::EcdsaProvider > ecdsa_provider, std::shared_ptr< const crypto::Ed25519Provider > ed25519_provider, std::shared_ptr< const crypto::Secp256k1Provider > secp256k1_provider, std::shared_ptr< const crypto::Hasher > hasher, std::shared_ptr< crypto::CryptoStore > crypto_store, std::shared_ptr< const crypto::Bip39Provider > bip39_provider, std::shared_ptr< offchain::OffchainPersistentStorage > offchain_persistent_storage, std::shared_ptr< offchain::OffchainWorkerPool > offchain_worker_pool) | |
~HostApiImpl () override=default | |
void | reset () override |
runtime::WasmSpan | ext_storage_read_version_1 (runtime::WasmSpan key, runtime::WasmSpan value_out, runtime::WasmOffset offset) override |
Reads data from storage with the given key. More... | |
void | ext_storage_set_version_1 (runtime::WasmSpan key, runtime::WasmSpan value) override |
Sets the value under a given key into storage. More... | |
runtime::WasmSpan | ext_storage_get_version_1 (runtime::WasmSpan key) override |
Retrieves the value associated with the given key from storage. More... | |
void | ext_storage_clear_version_1 (runtime::WasmSpan key_data) override |
Clears the storage of the given key and its value. More... | |
runtime::WasmSize | ext_storage_exists_version_1 (runtime::WasmSpan key_data) const override |
Checks whether the given key exists in storage. More... | |
void | ext_storage_clear_prefix_version_1 (runtime::WasmSpan prefix) override |
Clear the storage of each key/value pair where the key starts with the given prefix. More... | |
runtime::WasmSpan | ext_storage_clear_prefix_version_2 (runtime::WasmSpan prefix, runtime::WasmSpan limit) override |
Clear the storage of each key/value pair where the key starts with the given prefix. More... | |
runtime::WasmSpan | ext_storage_root_version_1 () override |
Commits all existing operations and computes the resulting storage root. More... | |
runtime::WasmSpan | ext_storage_root_version_2 (runtime::WasmI32 state_version) override |
Commits all existing operations and computes the resulting storage root. More... | |
runtime::WasmSpan | ext_storage_changes_root_version_1 (runtime::WasmSpan parent_hash) override |
void | ext_storage_start_transaction_version_1 () override |
void | ext_storage_rollback_transaction_version_1 () override |
void | ext_storage_commit_transaction_version_1 () override |
runtime::WasmSpan | ext_storage_next_key_version_1 (runtime::WasmSpan key) const override |
void | ext_storage_append_version_1 (runtime::WasmSpan key, runtime::WasmSpan value) const override |
runtime::WasmPointer | ext_trie_blake2_256_root_version_1 (runtime::WasmSpan values_data) override |
runtime::WasmPointer | ext_trie_blake2_256_ordered_root_version_1 (runtime::WasmSpan values_data) override |
runtime::WasmPointer | ext_trie_blake2_256_ordered_root_version_2 (runtime::WasmSpan values_data, runtime::WasmI32 state_version) override |
runtime::WasmPointer | ext_allocator_malloc_version_1 (runtime::WasmSize size) override |
void | ext_allocator_free_version_1 (runtime::WasmPointer ptr) override |
void | ext_crypto_start_batch_verify_version_1 () override |
Crypto extensions v1. More... | |
int32_t | ext_crypto_finish_batch_verify_version_1 () override |
Finish verifying the batch of signatures since the last call to this function. Blocks until all the signatures are verified. More... | |
runtime::WasmSpan | ext_crypto_secp256k1_ecdsa_recover_version_1 (runtime::WasmPointer sig, runtime::WasmPointer msg) override |
runtime::WasmSpan | ext_crypto_secp256k1_ecdsa_recover_version_2 (runtime::WasmPointer sig, runtime::WasmPointer msg) override |
runtime::WasmSpan | ext_crypto_secp256k1_ecdsa_recover_compressed_version_1 (runtime::WasmPointer sig, runtime::WasmPointer msg) override |
runtime::WasmSpan | ext_crypto_secp256k1_ecdsa_recover_compressed_version_2 (runtime::WasmPointer sig, runtime::WasmPointer msg) override |
runtime::WasmSpan | ext_crypto_ed25519_public_keys_version_1 (runtime::WasmSize key_type) override |
runtime::WasmPointer | ext_crypto_ed25519_generate_version_1 (runtime::WasmSize key_type, runtime::WasmSpan seed) override |
runtime::WasmSpan | ext_crypto_ed25519_sign_version_1 (runtime::WasmSize key_type, runtime::WasmPointer key, runtime::WasmSpan msg_data) override |
runtime::WasmSize | ext_crypto_ed25519_verify_version_1 (runtime::WasmPointer sig_data, runtime::WasmSpan msg, runtime::WasmPointer pubkey_data) override |
runtime::WasmSpan | ext_crypto_sr25519_public_keys_version_1 (runtime::WasmSize key_type) override |
runtime::WasmPointer | ext_crypto_sr25519_generate_version_1 (runtime::WasmSize key_type, runtime::WasmSpan seed) override |
runtime::WasmSpan | ext_crypto_sr25519_sign_version_1 (runtime::WasmSize key_type, runtime::WasmPointer key, runtime::WasmSpan msg_data) override |
int32_t | ext_crypto_sr25519_verify_version_1 (runtime::WasmPointer sig_data, runtime::WasmSpan msg, runtime::WasmPointer pubkey_data) override |
int32_t | ext_crypto_sr25519_verify_version_2 (runtime::WasmPointer, runtime::WasmSpan, runtime::WasmPointer) override |
runtime::WasmSpan | ext_crypto_ecdsa_public_keys_version_1 (runtime::WasmSize key_type) override |
runtime::WasmSpan | ext_crypto_ecdsa_sign_version_1 (runtime::WasmSize key_type, runtime::WasmPointer key, runtime::WasmSpan msg_data) override |
runtime::WasmSpan | ext_crypto_ecdsa_sign_prehashed_version_1 (runtime::WasmSize key_type, runtime::WasmPointer key, runtime::WasmSpan msg_data) override |
runtime::WasmPointer | ext_crypto_ecdsa_generate_version_1 (runtime::WasmSize key_type_id, runtime::WasmSpan seed) override |
Generates an ecdsa key for the given key type using an optional BIP-39 seed and stores it in the keystore. Warning: Panics if the key cannot be generated, such as when an invalid key type or invalid seed was provided. More... | |
int32_t | ext_crypto_ecdsa_verify_version_1 (runtime::WasmPointer sig, runtime::WasmSpan msg, runtime::WasmPointer key) override |
Verifies an ecdsa signature. Returns true when the verification is either successful or batched. If no batching verification extension is registered, this function will fully verify the signature and return the result. If batching verification is registered, this function will push the data to the batch and return immediately. The caller can then get the result by calling ext_crypto_finish_batch_verify. The verification extension is explained more in detail in ext_crypto_start_batch_verify. More... | |
int32_t | ext_crypto_ecdsa_verify_prehashed_version_1 (runtime::WasmPointer sig, runtime::WasmSpan msg, runtime::WasmPointer key) override |
Verifies an ecdsa signature. Returns true when the verification is either successful or batched. If no batching verification extension is registered, this function will fully verify the signature and return the result. If batching verification is registered, this function will push the data to the batch and return immediately. The caller can then get the result by calling ext_crypto_finish_batch_verify. The verification extension is explained more in detail in ext_crypto_start_batch_verify. More... | |
runtime::WasmPointer | ext_hashing_keccak_256_version_1 (runtime::WasmSpan data) override |
runtime::WasmPointer | ext_hashing_sha2_256_version_1 (runtime::WasmSpan data) override |
runtime::WasmPointer | ext_hashing_blake2_128_version_1 (runtime::WasmSpan data) override |
runtime::WasmPointer | ext_hashing_blake2_256_version_1 (runtime::WasmSpan data) override |
runtime::WasmPointer | ext_hashing_twox_64_version_1 (runtime::WasmSpan data) override |
runtime::WasmPointer | ext_hashing_twox_128_version_1 (runtime::WasmSpan data) override |
runtime::WasmPointer | ext_hashing_twox_256_version_1 (runtime::WasmSpan data) override |
void | ext_logging_log_version_1 (runtime::WasmEnum level, runtime::WasmSpan target, runtime::WasmSpan message) override |
runtime::WasmEnum | ext_logging_max_level_version_1 () override |
runtime::WasmSpan | ext_misc_runtime_version_version_1 (runtime::WasmSpan data) const override |
void | ext_misc_print_hex_version_1 (runtime::WasmSpan data) const override |
void | ext_misc_print_num_version_1 (uint64_t value) const override |
void | ext_misc_print_utf8_version_1 (runtime::WasmSpan data) const override |
runtime::WasmI32 | ext_offchain_is_validator_version_1 () override |
Check whether the local node is a potential validator. Even if this function returns 1, it does not mean that any keys are configured or that the validator is registered in the chain. More... | |
runtime::WasmSpan | ext_offchain_submit_transaction_version_1 (runtime::WasmSpan data) override |
Given a SCALE encoded extrinsic, this function submits the extrinsic to the Host's transaction pool, ready to be propagated to remote peers. More... | |
runtime::WasmSpan | ext_offchain_network_state_version_1 () override |
Returns the SCALE encoded, opaque information about the local node's network state. More... | |
runtime::WasmU64 | ext_offchain_timestamp_version_1 () override |
Returns current timestamp. More... | |
void | ext_offchain_sleep_until_version_1 (runtime::WasmU64 deadline) override |
Pause the execution until deadline is reached. More... | |
runtime::WasmPointer | ext_offchain_random_seed_version_1 () override |
Generates a random seed. This is a truly random non deterministic seed generated by the host environment. More... | |
void | ext_offchain_local_storage_set_version_1 (runtime::WasmI32 kind, runtime::WasmSpan key, runtime::WasmSpan value) override |
Sets a value in the local storage. This storage is not part of the consensus, it's only accessible by the offchain worker tasks running on the same machine and is persisted between runs. More... | |
void | ext_offchain_local_storage_clear_version_1 (runtime::WasmI32 kind, runtime::WasmSpan key) override |
Remove a value from the local storage. More... | |
runtime::WasmI32 | ext_offchain_local_storage_compare_and_set_version_1 (runtime::WasmI32 kind, runtime::WasmSpan key, runtime::WasmSpan expected, runtime::WasmSpan value) override |
runtime::WasmSpan | ext_offchain_local_storage_get_version_1 (runtime::WasmI32 kind, runtime::WasmSpan key) override |
Gets a value from the local storage. More... | |
runtime::WasmSpan | ext_offchain_http_request_start_version_1 (runtime::WasmSpan method, runtime::WasmSpan uri, runtime::WasmSpan meta) override |
Initiates a HTTP request given by the HTTP method and the URL. Returns the id of a newly started request. More... | |
runtime::WasmSpan | ext_offchain_http_request_add_header_version_1 (runtime::WasmI32 request_id, runtime::WasmSpan name, runtime::WasmSpan value) override |
runtime::WasmSpan | ext_offchain_http_request_write_body_version_1 (runtime::WasmI32 request_id, runtime::WasmSpan chunk, runtime::WasmSpan deadline) override |
runtime::WasmSpan | ext_offchain_http_response_wait_version_1 (runtime::WasmSpan ids, runtime::WasmSpan deadline) override |
Returns an array of request statuses (the length is the same as IDs). Note that if deadline is not provided the method will block indefinitely, otherwise unready responses will produce DeadlineReached status. More... | |
runtime::WasmSpan | ext_offchain_http_response_headers_version_1 (runtime::WasmI32 request_id) override |
Read all HTTP response headers. Returns an array of key/value pairs. Response headers must be read before the response body. More... | |
runtime::WasmSpan | ext_offchain_http_response_read_body_version_1 (runtime::WasmI32 request_id, runtime::WasmSpan buffer, runtime::WasmSpan deadline) override |
void | ext_offchain_set_authorized_nodes_version_1 (runtime::WasmSpan nodes, runtime::WasmI32 authorized_only) override |
Set the authorized nodes which are allowed to connect to the local node. This function is offered by the Substrate codebase and is primarily used for custom, non-Polkadot/Kusama chains. It is not required for the public and open Polkadot protocol. More... | |
void | ext_offchain_index_set_version_1 (runtime::WasmSpan key, runtime::WasmSpan value) override |
Write a key value pair to the offchain database in a buffered fashion. More... | |
void | ext_offchain_index_clear_version_1 (runtime::WasmSpan key) override |
Remove a key and its associated value from the offchain database. More... | |
void | ext_default_child_storage_set_version_1 (runtime::WasmSpan child_storage_key, runtime::WasmSpan key, runtime::WasmSpan value) override |
Sets the value under a given key into the child storage. More... | |
runtime::WasmSpan | ext_default_child_storage_get_version_1 (runtime::WasmSpan child_storage_key, runtime::WasmSpan key) const override |
Retrieves the value associated with the given key from the child storage. More... | |
void | ext_default_child_storage_clear_version_1 (runtime::WasmSpan child_storage_key, runtime::WasmSpan key) override |
Clears the storage of the given key and its value from the child storage. More... | |
runtime::WasmSpan | ext_default_child_storage_next_key_version_1 (runtime::WasmSpan child_storage_key, runtime::WasmSpan key) const override |
Gets the next key in storage after the given one in lexicographic order. The key provided to this function may or may not exist in storage. More... | |
runtime::WasmSpan | ext_default_child_storage_root_version_1 (runtime::WasmSpan child_storage_key) const override |
Commits all existing operations and computes the resulting child storage root. More... | |
void | ext_default_child_storage_clear_prefix_version_1 (runtime::WasmSpan child_storage_key, runtime::WasmSpan prefix) override |
Clears the child storage of each key/value pair where the key starts with the given prefix. More... | |
virtual runtime::WasmSpan | ext_default_child_storage_read_version_1 (runtime::WasmSpan child_storage_key, runtime::WasmSpan key, runtime::WasmSpan value_out, runtime::WasmOffset offset) const override |
Gets the given key from storage, placing the value into a buffer and returning the number of bytes that the entry in storage has beyond the offset. More... | |
virtual uint32_t | ext_default_child_storage_exists_version_1 (runtime::WasmSpan child_storage_key, runtime::WasmSpan key) const override |
Checks whether the given key exists in the child storage. More... | |
virtual void | ext_default_child_storage_storage_kill_version_1 (runtime::WasmSpan child_storage_key) override |
Clears an entire child storage. More... | |
Public Member Functions inherited from kagome::host_api::HostApi | |
virtual | ~HostApi ()=default |
Private Attributes | |
std::shared_ptr< const runtime::MemoryProvider > | memory_provider_ |
std::shared_ptr< runtime::TrieStorageProvider > | storage_provider_ |
CryptoExtension | crypto_ext_ |
IOExtension | io_ext_ |
MemoryExtension | memory_ext_ |
MiscExtension | misc_ext_ |
StorageExtension | storage_ext_ |
ChildStorageExtension | child_storage_ext_ |
OffchainExtension | offchain_ext_ |
Static Private Attributes | |
static constexpr uint64_t | DEFAULT_CHAIN_ID = 42 |
Fair implementation of the extensions interface
Definition at line 33 of file host_api_impl.hpp.
|
delete |
kagome::host_api::HostApiImpl::HostApiImpl | ( | const OffchainExtensionConfig & | offchain_config, |
std::shared_ptr< const runtime::MemoryProvider > | memory_provider, | ||
std::shared_ptr< const runtime::CoreApiFactory > | core_provider, | ||
std::shared_ptr< runtime::TrieStorageProvider > | storage_provider, | ||
std::shared_ptr< const crypto::Sr25519Provider > | sr25519_provider, | ||
std::shared_ptr< const crypto::EcdsaProvider > | ecdsa_provider, | ||
std::shared_ptr< const crypto::Ed25519Provider > | ed25519_provider, | ||
std::shared_ptr< const crypto::Secp256k1Provider > | secp256k1_provider, | ||
std::shared_ptr< const crypto::Hasher > | hasher, | ||
std::shared_ptr< crypto::CryptoStore > | crypto_store, | ||
std::shared_ptr< const crypto::Bip39Provider > | bip39_provider, | ||
std::shared_ptr< offchain::OffchainPersistentStorage > | offchain_persistent_storage, | ||
std::shared_ptr< offchain::OffchainWorkerPool > | offchain_worker_pool | ||
) |
Definition at line 21 of file host_api_impl.cpp.
|
overridedefault |
|
overridevirtual |
Implements kagome::host_api::HostApi.
Definition at line 163 of file host_api_impl.cpp.
|
overridevirtual |
Implements kagome::host_api::HostApi.
Definition at line 158 of file host_api_impl.cpp.
|
overridevirtual |
Generates an ecdsa key for the given key type using an optional BIP-39 seed and stores it in the keystore. Warning: Panics if the key cannot be generated, such as when an invalid key type or invalid seed was provided.
key_type_id | a 32-bit pointer to the key identifier |
seed | a pointer-size indicating the SCALE encoded Option containing the BIP-39 seed which must be valid UTF8. |
Implements kagome::host_api::HostApi.
Definition at line 267 of file host_api_impl.cpp.
|
overridevirtual |
Implements kagome::host_api::HostApi.
Definition at line 247 of file host_api_impl.cpp.
|
overridevirtual |
Signs the given message digest with a specified key
key_type | a 32-bit pointer to the key identifier |
key | a 32-bit pointer to the buffer containing the 33-byte compressed public key |
msg_data | a pointer-size indicating the message that is to be signed |
Implements kagome::host_api::HostApi.
Definition at line 259 of file host_api_impl.cpp.
|
overridevirtual |
Implements kagome::host_api::HostApi.
Definition at line 252 of file host_api_impl.cpp.
|
overridevirtual |
Verifies an ecdsa signature. Returns true when the verification is either successful or batched. If no batching verification extension is registered, this function will fully verify the signature and return the result. If batching verification is registered, this function will push the data to the batch and return immediately. The caller can then get the result by calling ext_crypto_finish_batch_verify. The verification extension is explained more in detail in ext_crypto_start_batch_verify.
sig | a 32-bit pointer to the buffer containing the 65-byte signature. The signature is 65- bytes in size, where the first 512-bits represent the signature and the other 8 bits represent the recovery ID. |
msg | a pointer-size as defined in Definition D.3 indicating the message that is to be verified. |
key | a 32-bit pointer to the buffer containing the 33-byte compressed public key. |
Implements kagome::host_api::HostApi.
Definition at line 279 of file host_api_impl.cpp.
|
overridevirtual |
Verifies an ecdsa signature. Returns true when the verification is either successful or batched. If no batching verification extension is registered, this function will fully verify the signature and return the result. If batching verification is registered, this function will push the data to the batch and return immediately. The caller can then get the result by calling ext_crypto_finish_batch_verify. The verification extension is explained more in detail in ext_crypto_start_batch_verify.
sig | a 32-bit pointer to the buffer containing the 65-byte signature. The signature is 65- bytes in size, where the first 512-bits represent the signature and the other 8 bits represent the recovery ID. |
msg | a pointer-size as defined in Definition D.3 indicating the message that is to be verified. |
key | a 32-bit pointer to the buffer containing the 33-byte compressed public key. |
Implements kagome::host_api::HostApi.
Definition at line 272 of file host_api_impl.cpp.
|
overridevirtual |
Implements kagome::host_api::HostApi.
Definition at line 192 of file host_api_impl.cpp.
|
overridevirtual |
Implements kagome::host_api::HostApi.
Definition at line 187 of file host_api_impl.cpp.
|
overridevirtual |
Implements kagome::host_api::HostApi.
Definition at line 197 of file host_api_impl.cpp.
|
overridevirtual |
Implements kagome::host_api::HostApi.
Definition at line 205 of file host_api_impl.cpp.
|
overridevirtual |
Finish verifying the batch of signatures since the last call to this function. Blocks until all the signatures are verified.
runtime_error | if no verification extension is registered (ext_crypto_start_batch_verify (E.3.15) tchwas not called.) |
Implements kagome::host_api::HostApi.
Definition at line 183 of file host_api_impl.cpp.
|
overridevirtual |
Recover secp256k1 public key
sig | recoverable 65-byte signature |
msg | blake2s message hash |
Implements kagome::host_api::HostApi.
Definition at line 353 of file host_api_impl.cpp.
|
overridevirtual |
Implements kagome::host_api::HostApi.
Definition at line 360 of file host_api_impl.cpp.
|
overridevirtual |
Recover secp256k1 public key
sig | recoverable 65-byte signature |
msg | blake2s message hash |
Implements kagome::host_api::HostApi.
Definition at line 342 of file host_api_impl.cpp.
|
overridevirtual |
Implements kagome::host_api::HostApi.
Definition at line 347 of file host_api_impl.cpp.
|
overridevirtual |
Implements kagome::host_api::HostApi.
Definition at line 218 of file host_api_impl.cpp.
|
overridevirtual |
Implements kagome::host_api::HostApi.
Definition at line 213 of file host_api_impl.cpp.
|
overridevirtual |
Implements kagome::host_api::HostApi.
Definition at line 223 of file host_api_impl.cpp.
|
overridevirtual |
Verifies an sr25519 signature. Only version 1 of this function supports deprecated Schnorr signatures introduced by the schnorrkel Rust library version 0.1.1 and should only be used for backward compatibility. Returns true when the verification is either successful or batched. If no batching verification extension is registered, this function will fully verify the signature and return the result. If batching verification is registered, this function will push the data to the batch and return immediately. The caller can then get the result by calling ext_crypto_finish_batch_verify The verification extension is explained more in detail in ext_crypto_start_batch_verify
Implements kagome::host_api::HostApi.
Definition at line 231 of file host_api_impl.cpp.
|
overridevirtual |
Implements kagome::host_api::HostApi.
Definition at line 239 of file host_api_impl.cpp.
|
overridevirtual |
Crypto extensions v1.
Implements kagome::host_api::HostApi.
Definition at line 179 of file host_api_impl.cpp.
|
overridevirtual |
Clears the child storage of each key/value pair where the key starts with the given prefix.
child_storage_key | a pointer-size indicating the child storage key |
prefix | a pointer-size indicating the prefix |
Implements kagome::host_api::HostApi.
Definition at line 509 of file host_api_impl.cpp.
|
overridevirtual |
Clears the storage of the given key and its value from the child storage.
child_storage_key | a pointer-size indicating the child storage key |
key | a pointer-size indicating the key |
Implements kagome::host_api::HostApi.
Definition at line 491 of file host_api_impl.cpp.
|
overridevirtual |
Checks whether the given key exists in the child storage.
child_storage_key | a pointer-size indicating the child storage key |
key | a pointer-size indicating the key. |
Implements kagome::host_api::HostApi.
Definition at line 524 of file host_api_impl.cpp.
|
overridevirtual |
Retrieves the value associated with the given key from the child storage.
child_storage_key | a pointer-size indicating the child storage key |
key | a pointer-size indicating the key. |
Implements kagome::host_api::HostApi.
Definition at line 485 of file host_api_impl.cpp.
|
overridevirtual |
Gets the next key in storage after the given one in lexicographic order. The key provided to this function may or may not exist in storage.
child_storage_key | a pointer-size indicating the child storage key |
key | a pointer-size indicating the key. |
Implements kagome::host_api::HostApi.
Definition at line 497 of file host_api_impl.cpp.
|
overridevirtual |
Gets the given key from storage, placing the value into a buffer and returning the number of bytes that the entry in storage has beyond the offset.
child_storage_key | a pointer-size indicating the child storage key |
key | a pointer-size as defined in Definition D.3 indicating the key. |
value_out | a pointer-size as defined in Definition D.3 indicating the buffer to which the value will be written to. This function will never write more then the length of the buffer, even if the value's length is bigger. |
offset | an i32 integer containing the offset beyond the value should be read from. |
Implements kagome::host_api::HostApi.
Definition at line 515 of file host_api_impl.cpp.
|
overridevirtual |
Commits all existing operations and computes the resulting child storage root.
child_storage_key | a pointer-size indicating the child storage key |
Implements kagome::host_api::HostApi.
Definition at line 503 of file host_api_impl.cpp.
|
overridevirtual |
Sets the value under a given key into the child storage.
child_storage_key | a pointer-size indicating the child storage key |
key | a pointer-size indicating the key. |
value | a pointer-size indicating the value. |
Implements kagome::host_api::HostApi.
Definition at line 477 of file host_api_impl.cpp.
|
overridevirtual |
Clears an entire child storage.
child_storage_key | a pointer-size indicating the child storage key |
Implements kagome::host_api::HostApi.
Definition at line 530 of file host_api_impl.cpp.
|
overridevirtual |
Implements kagome::host_api::HostApi.
Definition at line 299 of file host_api_impl.cpp.
|
overridevirtual |
Implements kagome::host_api::HostApi.
Definition at line 304 of file host_api_impl.cpp.
|
overridevirtual |
Implements kagome::host_api::HostApi.
Definition at line 289 of file host_api_impl.cpp.
|
overridevirtual |
Implements kagome::host_api::HostApi.
Definition at line 294 of file host_api_impl.cpp.
|
overridevirtual |
Implements kagome::host_api::HostApi.
Definition at line 314 of file host_api_impl.cpp.
|
overridevirtual |
Implements kagome::host_api::HostApi.
Definition at line 319 of file host_api_impl.cpp.
|
overridevirtual |
Implements kagome::host_api::HostApi.
Definition at line 309 of file host_api_impl.cpp.
|
overridevirtual |
Print a log message
level | - log level of the message |
target | pointer-size value of the message source |
message | pointer-size value of the message content |
Implements kagome::host_api::HostApi.
Definition at line 167 of file host_api_impl.cpp.
|
overridevirtual |
Get host max log level
Implements kagome::host_api::HostApi.
Definition at line 173 of file host_api_impl.cpp.
|
overridevirtual |
Print a hex value
data | pointer-size to an array of bytes with hex |
Implements kagome::host_api::HostApi.
Definition at line 329 of file host_api_impl.cpp.
|
overridevirtual |
Print a number
value | - number to be printed |
Implements kagome::host_api::HostApi.
Definition at line 333 of file host_api_impl.cpp.
|
overridevirtual |
Print a UTF-8-encoded string
data | pointer-size to an array of bytes with UTF-8 |
Implements kagome::host_api::HostApi.
Definition at line 337 of file host_api_impl.cpp.
|
overridevirtual |
Implements kagome::host_api::HostApi.
Definition at line 324 of file host_api_impl.cpp.
|
overridevirtual |
OffchainExtension::ext_offchain_http_request_add_header_version_1
Implements kagome::host_api::HostApi.
Definition at line 426 of file host_api_impl.cpp.
|
overridevirtual |
Initiates a HTTP request given by the HTTP method and the URL. Returns the id of a newly started request.
method | a pointer-size indicating the HTTP method. Possible values are "GET" and "POST" |
uri | a pointer-size indicating the URI |
meta | a future-reserved field containing additional, SCALE encoded parameters. Currently, an empty array should be passed |
Result
containing the i16
ID of the newly started request. On failure no additionally data is provided. The cause of failure is implementation specific Implements kagome::host_api::HostApi.
Definition at line 420 of file host_api_impl.cpp.
|
overridevirtual |
OffchainExtension::ext_offchain_http_request_write_body_version_1
Implements kagome::host_api::HostApi.
Definition at line 434 of file host_api_impl.cpp.
|
overridevirtual |
Read all HTTP response headers. Returns an array of key/value pairs. Response headers must be read before the response body.
request_id | an i32 integer indicating the ID of the started request |
Implements kagome::host_api::HostApi.
Definition at line 448 of file host_api_impl.cpp.
|
overridevirtual |
OffchainExtension::ext_offchain_http_response_read_body_version_1
Implements kagome::host_api::HostApi.
Definition at line 454 of file host_api_impl.cpp.
|
overridevirtual |
Returns an array of request statuses (the length is the same as IDs). Note that if deadline is not provided the method will block indefinitely, otherwise unready responses will produce DeadlineReached status.
ids | a pointer-size indicating the SCALE encoded array of started request IDs |
deadline | a pointer-size indicating the SCALE encoded Option containing the UNIX timestamp. Passing None blocks indefinitely |
Implements kagome::host_api::HostApi.
Definition at line 442 of file host_api_impl.cpp.
|
overridevirtual |
Remove a key and its associated value from the offchain database.
key | a pointer-size indicating the key |
Implements kagome::host_api::HostApi.
Definition at line 473 of file host_api_impl.cpp.
|
overridevirtual |
Write a key value pair to the offchain database in a buffered fashion.
key | a pointer-size indicating the key |
value | a pointer-size indicating the value |
Implements kagome::host_api::HostApi.
Definition at line 468 of file host_api_impl.cpp.
|
overridevirtual |
Check whether the local node is a potential validator. Even if this function returns 1, it does not mean that any keys are configured or that the validator is registered in the chain.
Implements kagome::host_api::HostApi.
Definition at line 368 of file host_api_impl.cpp.
|
overridevirtual |
Remove a value from the local storage.
kind | an i32 integer indicating the storage kind. A value equal to 1 is used for a persistent storage and a value equal to 2 for local storage |
key | a pointer-size indicating the key |
Implements kagome::host_api::HostApi.
Definition at line 400 of file host_api_impl.cpp.
|
overridevirtual |
OffchainExtension::ext_offchain_local_storage_compare_and_set_version_1
Implements kagome::host_api::HostApi.
Definition at line 406 of file host_api_impl.cpp.
|
overridevirtual |
Gets a value from the local storage.
kind | an i32 integer indicating the storage kind. A value equal to 1 is used for a persistent storage and a value equal to 2 for local storage |
key | a pointer-size indicating the key |
Option
containing the value or the corresponding key Implements kagome::host_api::HostApi.
Definition at line 415 of file host_api_impl.cpp.
|
overridevirtual |
Sets a value in the local storage. This storage is not part of the consensus, it's only accessible by the offchain worker tasks running on the same machine and is persisted between runs.
kind | an i32 integer indicating the storage kind. A value equal to 1 is used for a persistent storage and a value equal to 2 for local storage |
key | a pointer-size indicating the key |
value | a pointer-size indicating the value |
Implements kagome::host_api::HostApi.
Definition at line 394 of file host_api_impl.cpp.
|
overridevirtual |
Returns the SCALE encoded, opaque information about the local node's network state.
Result
. On success it contains the OpaqueNetworkState
structure. On failure, an empty value is yielded where its cause is implementation specific Implements kagome::host_api::HostApi.
Definition at line 377 of file host_api_impl.cpp.
|
overridevirtual |
Generates a random seed. This is a truly random non deterministic seed generated by the host environment.
Implements kagome::host_api::HostApi.
Definition at line 390 of file host_api_impl.cpp.
|
overridevirtual |
Set the authorized nodes which are allowed to connect to the local node. This function is offered by the Substrate codebase and is primarily used for custom, non-Polkadot/Kusama chains. It is not required for the public and open Polkadot protocol.
nodes | a pointer-size indicating the SCALE encoded array of libp2p PeerId's. Invalid PeerId's are silently ignored |
authorized_only | If set to 1, then only the authorized nodes are allowed to connect to the local node (whitelist). All other nodes are rejected. If set to 0, then no such restriction is placed |
Implements kagome::host_api::HostApi.
Definition at line 462 of file host_api_impl.cpp.
|
overridevirtual |
Pause the execution until deadline
is reached.
deadline | an u64 integer indicating the current UNIX timestamp (milliseconds) |
Implements kagome::host_api::HostApi.
Definition at line 385 of file host_api_impl.cpp.
|
overridevirtual |
Given a SCALE encoded extrinsic, this function submits the extrinsic to the Host's transaction pool, ready to be propagated to remote peers.
data | byte array storing the encoded extrinsic |
Result
. Neither on success or failure is there any additional data provided Implements kagome::host_api::HostApi.
Definition at line 372 of file host_api_impl.cpp.
|
overridevirtual |
Returns current timestamp.
Implements kagome::host_api::HostApi.
Definition at line 381 of file host_api_impl.cpp.
|
overridevirtual |
Appends the scale encoded value to the scale encoded storage item at the given key
key | memory span containing key |
value | memory span containing value that should be appended to storage item under the |
key |
Implements kagome::host_api::HostApi.
Definition at line 81 of file host_api_impl.cpp.
|
overridevirtual |
Commits all existing operations and gets the resulting change root. The parent hash is a SCALE encoded change root.
parent_hash | wasm span containing parent hash |
Implements kagome::host_api::HostApi.
Definition at line 124 of file host_api_impl.cpp.
|
overridevirtual |
Clear the storage of each key/value pair where the key starts with the given prefix.
prefix | memory span containing prefix |
Implements kagome::host_api::HostApi.
Definition at line 105 of file host_api_impl.cpp.
|
overridevirtual |
Clear the storage of each key/value pair where the key starts with the given prefix.
prefix | memory span containing prefix |
limit | of entries to be removed |
Implements kagome::host_api::HostApi.
Definition at line 110 of file host_api_impl.cpp.
|
overridevirtual |
Clears the storage of the given key and its value.
key_data | memory span containing key |
Implements kagome::host_api::HostApi.
Definition at line 96 of file host_api_impl.cpp.
|
overridevirtual |
Commit the last transaction started by ext_storage_start_transaction. Any changes made during that transaction are committed to the main state.
Implements kagome::host_api::HostApi.
Definition at line 137 of file host_api_impl.cpp.
|
overridevirtual |
Checks whether the given key exists in storage.
key_data | memory span containing key |
Implements kagome::host_api::HostApi.
Definition at line 100 of file host_api_impl.cpp.
|
overridevirtual |
Retrieves the value associated with the given key from storage.
key | key memory span containing key |
Implements kagome::host_api::HostApi.
Definition at line 91 of file host_api_impl.cpp.
|
overridevirtual |
Gets the next key in storage after the given one in lexicographic order.
key | memory span containing key |
Implements kagome::host_api::HostApi.
Definition at line 76 of file host_api_impl.cpp.
|
overridevirtual |
Reads data from storage with the given key.
key | pointer-size to the key |
value_out | pointer-size to the read data |
offset | in bytes from the data block begin should be read |
Implements kagome::host_api::HostApi.
Definition at line 69 of file host_api_impl.cpp.
|
overridevirtual |
Rollback the last transaction started by ext_storage_start_transaction. Any changes made during that transaction are discarded.
Implements kagome::host_api::HostApi.
Definition at line 133 of file host_api_impl.cpp.
|
overridevirtual |
Commits all existing operations and computes the resulting storage root.
Implements kagome::host_api::HostApi.
Definition at line 115 of file host_api_impl.cpp.
|
overridevirtual |
Commits all existing operations and computes the resulting storage root.
state_version | - is using state version, where 0 - state version 1 1 - node hashes |
Implements kagome::host_api::HostApi.
Definition at line 119 of file host_api_impl.cpp.
|
overridevirtual |
Sets the value under a given key into storage.
key | memory span containing key |
value | memory span containing value |
Implements kagome::host_api::HostApi.
Definition at line 86 of file host_api_impl.cpp.
|
overridevirtual |
Start a new nested transaction. This allows to either commit or roll back all changes that are made after this call. For every transaction there must be a matching call to either ext_storage_rollback_transaction or ext_storage_commit_transaction.
Implements kagome::host_api::HostApi.
Definition at line 129 of file host_api_impl.cpp.
|
overridevirtual |
Conducts a 256-bit Blake2 trie root formed from the enumerated items.
values_data | wasm span containing the enumerated items from which the trie root gets formed. The items consist of a SCALE encoded array containing only values, where the corresponding key of each value is the index of the item in the array, starting at 0. The keys are little-endian, fixed-size integers. |
Implements kagome::host_api::HostApi.
Definition at line 146 of file host_api_impl.cpp.
|
overridevirtual |
Implements kagome::host_api::HostApi.
Definition at line 151 of file host_api_impl.cpp.
|
overridevirtual |
Conducts a 256-bit Blake2 trie root formed from the iterated items.
values_data | wasm span containing the iterated items from which the trie root gets formed. The items consist of a SCALE encoded array containing arbitrary key/value pairs. |
Implements kagome::host_api::HostApi.
Definition at line 141 of file host_api_impl.cpp.
|
overridevirtual |
Implements kagome::host_api::HostApi.
Definition at line 65 of file host_api_impl.cpp.
|
private |
Definition at line 347 of file host_api_impl.hpp.
|
private |
Definition at line 342 of file host_api_impl.hpp.
|
staticprivate |
Definition at line 337 of file host_api_impl.hpp.
|
private |
Definition at line 343 of file host_api_impl.hpp.
|
private |
Definition at line 344 of file host_api_impl.hpp.
|
private |
Definition at line 339 of file host_api_impl.hpp.
|
private |
Definition at line 345 of file host_api_impl.hpp.
|
private |
Definition at line 348 of file host_api_impl.hpp.
|
private |
Definition at line 346 of file host_api_impl.hpp.
|
private |
Definition at line 340 of file host_api_impl.hpp.