From a51b41c929297459db6251f9575289862cbb37f6 Mon Sep 17 00:00:00 2001 From: bkchr Date: Tue, 26 Aug 2025 01:14:27 +0000 Subject: [PATCH] deploy: 85ca3ff275ded2e690c4c175d5333d12b139d863 --- 404.html | 2 +- approved/0001-agile-coretime.html | 2 +- approved/0005-coretime-interface.html | 2 +- approved/0007-system-collator-selection.html | 2 +- approved/0008-parachain-bootnodes-dht.html | 2 +- ...09-improved-net-light-client-requests.html | 2 +- approved/0010-burn-coretime-revenue.html | 2 +- ...12-process-for-adding-new-collectives.html | 2 +- ...uilder-and-core-runtime-apis-for-mbms.html | 2 +- ...rove-locking-mechanism-for-parachains.html | 2 +- approved/0017-coretime-market-redesign.html | 2 +- approved/0022-adopt-encointer-runtime.html | 2 +- approved/0026-sassafras-consensus.html | 2 +- approved/0032-minimal-relay.html | 2 +- approved/0042-extrinsics-state-version.html | 2 +- .../0043-storage-proof-size-hostfunction.html | 2 +- approved/0045-nft-deposits-asset-hub.html | 2 +- ...047-assignment-of-availability-chunks.html | 2 +- approved/0048-session-keys-runtime-api.html | 2 +- approved/0050-fellowship-salaries.html | 2 +- ...0056-one-transaction-per-notification.html | 2 +- .../0059-nodes-capabilities-discovery.html | 2 +- approved/0078-merkleized-metadata.html | 2 +- ...-general-transaction-extrinsic-format.html | 2 +- approved/0091-dht-record-creation-time.html | 2 +- approved/0097-unbonding_queue.html | 2 +- .../0099-transaction-extension-version.html | 2 +- .../0100-xcm-multi-type-asset-transfer.html | 2 +- ...-xcm-transact-remove-max-weight-param.html | 2 +- .../0103-introduce-core-index-commitment.html | 2 +- approved/0105-xcm-improved-fee-mechanism.html | 2 +- approved/0107-xcm-execution-hints.html | 2 +- approved/0108-xcm-remove-testnet-ids.html | 2 +- .../0122-alias-origin-on-asset-transfers.html | 2 +- ...storage-location-for-runtime-upgrades.html | 2 +- approved/0125-xcm-asset-metadata.html | 2 +- approved/0126-introduce-pvq.html | 2 +- approved/0135-compressed-blob-prefixes.html | 2 +- approved/0139-faster-erasure-coding.html | 2 +- approved/0146-deflationary-fee-proposal.html | 2 +- approved/0149-rfc-1-renewal-adjustment.html | 2 +- index.html | 2 +- introduction.html | 2 +- print.html | 1315 ++++++++++------- proposed/0000-rewards.html | 6 +- ...45-remove-unnecessary-allocator-usage.html | 747 ++++++++++ .../0151-crowdsourced-decision-deposits.html | 6 +- searchindex.js | 2 +- searchindex.json | 2 +- stale/0000-pre-elves_soft.html | 2 +- ...04-remove-unnecessary-allocator-usage.html | 2 +- ...namic-pricing-for-bulk-coretime-sales.html | 2 +- ...-absolute-location-account-derivation.html | 2 +- ...ction-voting-delegation-modifications.html | 2 +- stale/0044-rent-based-registration.html | 2 +- stale/0054-remove-heap-pages.html | 2 +- stale/0070-x-track-kusamanetwork.html | 2 +- stale/0073-referedum-deposit-track.html | 2 +- stale/0074-stateful-multisig-pallet.html | 2 +- ...gth-of-identity-pgp-fingerprint-value.html | 2 +- ...t-purchaser-reputation-reserved-cores.html | 2 +- ...0xx-secondary-marketplace-for-regions.html | 2 +- .../00xx-smart-contracts-coretime-chain.html | 2 +- ...2-offchain-parachain-runtime-upgrades.html | 2 +- stale/0106-xcm-remove-fees-mode.html | 2 +- stale/0111-pure-proxy-replication.html | 2 +- ...-state-response-message-in-state-sync.html | 2 +- stale/0114-secp256r1-hostfunction.html | 2 +- stale/0117-unbrick-collective.html | 2 +- ...enda-confirmation-by-candle-mechanism.html | 2 +- stale/0124-extrinsic-version-5.html | 2 +- .../0138-invulnerable-collator-election.html | 6 +- ...45-remove-unnecessary-allocator-usage.html | 508 ------- stale/0150-voting-while-delegating.html | 6 +- ...eference-coretime-market-for-polkadot.html | 2 +- ...ust Tipper Track Confirmation Periods.html | 2 +- stale/TODO-stale-nomination-reward-curve.html | 2 +- ...e-the-security-of-proof-of-possession.html | 2 +- 78 files changed, 1607 insertions(+), 1129 deletions(-) create mode 100644 proposed/0145-remove-unnecessary-allocator-usage.html delete mode 100644 stale/0145-remove-unnecessary-allocator-usage.html diff --git a/404.html b/404.html index 045afb5..a994d43 100644 --- a/404.html +++ b/404.html @@ -91,7 +91,7 @@ diff --git a/approved/0001-agile-coretime.html b/approved/0001-agile-coretime.html index 6cb9982..7fc150f 100644 --- a/approved/0001-agile-coretime.html +++ b/approved/0001-agile-coretime.html @@ -90,7 +90,7 @@ diff --git a/approved/0005-coretime-interface.html b/approved/0005-coretime-interface.html index b16ca33..22c63d4 100644 --- a/approved/0005-coretime-interface.html +++ b/approved/0005-coretime-interface.html @@ -90,7 +90,7 @@ diff --git a/approved/0007-system-collator-selection.html b/approved/0007-system-collator-selection.html index 714cb01..5fd8151 100644 --- a/approved/0007-system-collator-selection.html +++ b/approved/0007-system-collator-selection.html @@ -90,7 +90,7 @@ diff --git a/approved/0008-parachain-bootnodes-dht.html b/approved/0008-parachain-bootnodes-dht.html index 2256464..de2a921 100644 --- a/approved/0008-parachain-bootnodes-dht.html +++ b/approved/0008-parachain-bootnodes-dht.html @@ -90,7 +90,7 @@ diff --git a/approved/0009-improved-net-light-client-requests.html b/approved/0009-improved-net-light-client-requests.html index b39b283..0020526 100644 --- a/approved/0009-improved-net-light-client-requests.html +++ b/approved/0009-improved-net-light-client-requests.html @@ -90,7 +90,7 @@ diff --git a/approved/0010-burn-coretime-revenue.html b/approved/0010-burn-coretime-revenue.html index 1252f8f..209e2aa 100644 --- a/approved/0010-burn-coretime-revenue.html +++ b/approved/0010-burn-coretime-revenue.html @@ -90,7 +90,7 @@ diff --git a/approved/0012-process-for-adding-new-collectives.html b/approved/0012-process-for-adding-new-collectives.html index d1fc6a6..cce033f 100644 --- a/approved/0012-process-for-adding-new-collectives.html +++ b/approved/0012-process-for-adding-new-collectives.html @@ -90,7 +90,7 @@ diff --git a/approved/0013-prepare-blockbuilder-and-core-runtime-apis-for-mbms.html b/approved/0013-prepare-blockbuilder-and-core-runtime-apis-for-mbms.html index 950c8f4..ba8c815 100644 --- a/approved/0013-prepare-blockbuilder-and-core-runtime-apis-for-mbms.html +++ b/approved/0013-prepare-blockbuilder-and-core-runtime-apis-for-mbms.html @@ -90,7 +90,7 @@ diff --git a/approved/0014-improve-locking-mechanism-for-parachains.html b/approved/0014-improve-locking-mechanism-for-parachains.html index 6bad2ba..ae1da21 100644 --- a/approved/0014-improve-locking-mechanism-for-parachains.html +++ b/approved/0014-improve-locking-mechanism-for-parachains.html @@ -90,7 +90,7 @@ diff --git a/approved/0017-coretime-market-redesign.html b/approved/0017-coretime-market-redesign.html index 1bf6b1b..bec80c8 100644 --- a/approved/0017-coretime-market-redesign.html +++ b/approved/0017-coretime-market-redesign.html @@ -90,7 +90,7 @@ diff --git a/approved/0022-adopt-encointer-runtime.html b/approved/0022-adopt-encointer-runtime.html index 93aa829..e842010 100644 --- a/approved/0022-adopt-encointer-runtime.html +++ b/approved/0022-adopt-encointer-runtime.html @@ -90,7 +90,7 @@ diff --git a/approved/0026-sassafras-consensus.html b/approved/0026-sassafras-consensus.html index ee8a7de..b85a79d 100644 --- a/approved/0026-sassafras-consensus.html +++ b/approved/0026-sassafras-consensus.html @@ -90,7 +90,7 @@ diff --git a/approved/0032-minimal-relay.html b/approved/0032-minimal-relay.html index 3e459ff..7377a1c 100644 --- a/approved/0032-minimal-relay.html +++ b/approved/0032-minimal-relay.html @@ -90,7 +90,7 @@ diff --git a/approved/0042-extrinsics-state-version.html b/approved/0042-extrinsics-state-version.html index 867b8d6..bae55d3 100644 --- a/approved/0042-extrinsics-state-version.html +++ b/approved/0042-extrinsics-state-version.html @@ -90,7 +90,7 @@ diff --git a/approved/0043-storage-proof-size-hostfunction.html b/approved/0043-storage-proof-size-hostfunction.html index 81f7bfc..26dfecc 100644 --- a/approved/0043-storage-proof-size-hostfunction.html +++ b/approved/0043-storage-proof-size-hostfunction.html @@ -90,7 +90,7 @@ diff --git a/approved/0045-nft-deposits-asset-hub.html b/approved/0045-nft-deposits-asset-hub.html index e179262..11b856c 100644 --- a/approved/0045-nft-deposits-asset-hub.html +++ b/approved/0045-nft-deposits-asset-hub.html @@ -90,7 +90,7 @@ diff --git a/approved/0047-assignment-of-availability-chunks.html b/approved/0047-assignment-of-availability-chunks.html index 0fd7f64..6f3efdc 100644 --- a/approved/0047-assignment-of-availability-chunks.html +++ b/approved/0047-assignment-of-availability-chunks.html @@ -90,7 +90,7 @@ diff --git a/approved/0048-session-keys-runtime-api.html b/approved/0048-session-keys-runtime-api.html index ea010df..cf4a664 100644 --- a/approved/0048-session-keys-runtime-api.html +++ b/approved/0048-session-keys-runtime-api.html @@ -90,7 +90,7 @@ diff --git a/approved/0050-fellowship-salaries.html b/approved/0050-fellowship-salaries.html index bac6911..7e47044 100644 --- a/approved/0050-fellowship-salaries.html +++ b/approved/0050-fellowship-salaries.html @@ -90,7 +90,7 @@ diff --git a/approved/0056-one-transaction-per-notification.html b/approved/0056-one-transaction-per-notification.html index 7d32637..ceb8186 100644 --- a/approved/0056-one-transaction-per-notification.html +++ b/approved/0056-one-transaction-per-notification.html @@ -90,7 +90,7 @@ diff --git a/approved/0059-nodes-capabilities-discovery.html b/approved/0059-nodes-capabilities-discovery.html index 63fa0ec..f6e1fc9 100644 --- a/approved/0059-nodes-capabilities-discovery.html +++ b/approved/0059-nodes-capabilities-discovery.html @@ -90,7 +90,7 @@ diff --git a/approved/0078-merkleized-metadata.html b/approved/0078-merkleized-metadata.html index 0451c24..af4a627 100644 --- a/approved/0078-merkleized-metadata.html +++ b/approved/0078-merkleized-metadata.html @@ -90,7 +90,7 @@ diff --git a/approved/0084-general-transaction-extrinsic-format.html b/approved/0084-general-transaction-extrinsic-format.html index a3fcc55..f75ca97 100644 --- a/approved/0084-general-transaction-extrinsic-format.html +++ b/approved/0084-general-transaction-extrinsic-format.html @@ -90,7 +90,7 @@ diff --git a/approved/0091-dht-record-creation-time.html b/approved/0091-dht-record-creation-time.html index 87b3884..5ba1157 100644 --- a/approved/0091-dht-record-creation-time.html +++ b/approved/0091-dht-record-creation-time.html @@ -90,7 +90,7 @@ diff --git a/approved/0097-unbonding_queue.html b/approved/0097-unbonding_queue.html index 847fb01..5bd21e9 100644 --- a/approved/0097-unbonding_queue.html +++ b/approved/0097-unbonding_queue.html @@ -90,7 +90,7 @@ diff --git a/approved/0099-transaction-extension-version.html b/approved/0099-transaction-extension-version.html index e0257e1..615ad85 100644 --- a/approved/0099-transaction-extension-version.html +++ b/approved/0099-transaction-extension-version.html @@ -90,7 +90,7 @@ diff --git a/approved/0100-xcm-multi-type-asset-transfer.html b/approved/0100-xcm-multi-type-asset-transfer.html index db4ca34..bf28f66 100644 --- a/approved/0100-xcm-multi-type-asset-transfer.html +++ b/approved/0100-xcm-multi-type-asset-transfer.html @@ -90,7 +90,7 @@ diff --git a/approved/0101-xcm-transact-remove-max-weight-param.html b/approved/0101-xcm-transact-remove-max-weight-param.html index b83e191..7fb3d30 100644 --- a/approved/0101-xcm-transact-remove-max-weight-param.html +++ b/approved/0101-xcm-transact-remove-max-weight-param.html @@ -90,7 +90,7 @@ diff --git a/approved/0103-introduce-core-index-commitment.html b/approved/0103-introduce-core-index-commitment.html index 6034249..ea3275f 100644 --- a/approved/0103-introduce-core-index-commitment.html +++ b/approved/0103-introduce-core-index-commitment.html @@ -90,7 +90,7 @@ diff --git a/approved/0105-xcm-improved-fee-mechanism.html b/approved/0105-xcm-improved-fee-mechanism.html index 2e984ea..18895f9 100644 --- a/approved/0105-xcm-improved-fee-mechanism.html +++ b/approved/0105-xcm-improved-fee-mechanism.html @@ -90,7 +90,7 @@ diff --git a/approved/0107-xcm-execution-hints.html b/approved/0107-xcm-execution-hints.html index e042bc5..edd4c0a 100644 --- a/approved/0107-xcm-execution-hints.html +++ b/approved/0107-xcm-execution-hints.html @@ -90,7 +90,7 @@ diff --git a/approved/0108-xcm-remove-testnet-ids.html b/approved/0108-xcm-remove-testnet-ids.html index f91bb4f..fc5d20f 100644 --- a/approved/0108-xcm-remove-testnet-ids.html +++ b/approved/0108-xcm-remove-testnet-ids.html @@ -90,7 +90,7 @@ diff --git a/approved/0122-alias-origin-on-asset-transfers.html b/approved/0122-alias-origin-on-asset-transfers.html index 2cd4274..8227ec7 100644 --- a/approved/0122-alias-origin-on-asset-transfers.html +++ b/approved/0122-alias-origin-on-asset-transfers.html @@ -90,7 +90,7 @@ diff --git a/approved/0123-pending-code-as-storage-location-for-runtime-upgrades.html b/approved/0123-pending-code-as-storage-location-for-runtime-upgrades.html index c5162ad..eb23393 100644 --- a/approved/0123-pending-code-as-storage-location-for-runtime-upgrades.html +++ b/approved/0123-pending-code-as-storage-location-for-runtime-upgrades.html @@ -90,7 +90,7 @@ diff --git a/approved/0125-xcm-asset-metadata.html b/approved/0125-xcm-asset-metadata.html index b98f5d3..4c5bdb4 100644 --- a/approved/0125-xcm-asset-metadata.html +++ b/approved/0125-xcm-asset-metadata.html @@ -90,7 +90,7 @@ diff --git a/approved/0126-introduce-pvq.html b/approved/0126-introduce-pvq.html index ef7513f..a57fe9f 100644 --- a/approved/0126-introduce-pvq.html +++ b/approved/0126-introduce-pvq.html @@ -90,7 +90,7 @@ diff --git a/approved/0135-compressed-blob-prefixes.html b/approved/0135-compressed-blob-prefixes.html index 7ce6b16..9d2a98f 100644 --- a/approved/0135-compressed-blob-prefixes.html +++ b/approved/0135-compressed-blob-prefixes.html @@ -90,7 +90,7 @@ diff --git a/approved/0139-faster-erasure-coding.html b/approved/0139-faster-erasure-coding.html index 719439b..5514f32 100644 --- a/approved/0139-faster-erasure-coding.html +++ b/approved/0139-faster-erasure-coding.html @@ -90,7 +90,7 @@ diff --git a/approved/0146-deflationary-fee-proposal.html b/approved/0146-deflationary-fee-proposal.html index 460cc3e..3367d18 100644 --- a/approved/0146-deflationary-fee-proposal.html +++ b/approved/0146-deflationary-fee-proposal.html @@ -90,7 +90,7 @@ diff --git a/approved/0149-rfc-1-renewal-adjustment.html b/approved/0149-rfc-1-renewal-adjustment.html index 43cc3eb..1e91dc5 100644 --- a/approved/0149-rfc-1-renewal-adjustment.html +++ b/approved/0149-rfc-1-renewal-adjustment.html @@ -90,7 +90,7 @@ diff --git a/index.html b/index.html index 93d80a3..094e6a2 100644 --- a/index.html +++ b/index.html @@ -90,7 +90,7 @@ diff --git a/introduction.html b/introduction.html index 93d80a3..094e6a2 100644 --- a/introduction.html +++ b/introduction.html @@ -90,7 +90,7 @@ diff --git a/print.html b/print.html index 188e92f..06157b2 100644 --- a/print.html +++ b/print.html @@ -91,7 +91,7 @@ @@ -420,6 +420,525 @@ At this point, we compute $\beta\prime_w = \sum_v \beta\prime_{w,v}$ on-chain fo

Synthetic parachain flag

Any rewards protocol could simply be "out voted" by too many slow validators: An increase the number of parachain cores increases more workload, but this creates no-shows if too few validators could handle this workload.

We could add a synthetic parachain flag, only settable by governance, which treats no-shows as positive approval votes for that parachain, but without adding rewards. We should never enable this for real parachains, only for synthetic ones like gluttons. We should not enable the synthetic parachain flag long-term even for gluttonsm, because validators could easily modify their code. Yet, synthetic approval checks might enable pushing the hardware upgrades more agressively over the short-term.

+

(source)

+

Table of Contents

+ +

RFC-0145: Remove the host-side runtime memory allocator

+
+ + + + +
Start Date2025-05-16
DescriptionUpdate the runtime-host interface to no longer make use of a host-side allocator
AuthorsPierre Krieger, Someone Unknown
+
+

Summary

+

Update the runtime-host interface so that it no longer uses the host-side allocator.

+

Prior Art

+

The API of these new functions was heavily inspired by the API used by the C programming language.

+

This RFC is mainly based on RFC-4 by @tomaka, which was never adopted, and this RFC supersedes it.

+

Changes from RFC-4

+ +

Motivation

+

The heap allocation of the runtime is currently controlled by the host using a memory allocator on the host side.

+

The API of many host functions contains buffer allocations. For example, when calling ext_hashing_twox_256_version_1, the host allocates a 32-byte buffer using the host allocator, and returns a pointer to this buffer to the runtime. The runtime later has to call ext_allocator_free_version_1 on this pointer to free the buffer.

+

Even though no benchmark has been done, it is pretty obvious that this design is very inefficient. To continue with the example of ext_hashing_twox_256_version_1, it would be more efficient to instead write the output hash to a buffer allocated by the runtime on its stack and passed by pointer to the function. Allocating a buffer on the stack, in the worst case, consists simply of decreasing a number; in the best case, it is free. Doing so would save many VM memory reads and writes by the allocator, and would save a function call to ext_allocator_free_version_1.

+

Furthermore, the existence of the host-side allocator has become questionable over time. It is implemented in a very naive way, and for determinism and backwards compatibility reasons, it needs to be implemented exactly identically in every client implementation. Runtimes make substantial use of heap memory allocations, and each allocation needs to go through the runtime <-> host boundary twice (once for allocating and once for freeing). Moving the allocator to the runtime side would be a good idea, although it would increase the runtime size. But before the host-side allocator can be deprecated, all the host functions that use it must be updated to avoid using it.

+

Stakeholders

+

No attempt was made to convince stakeholders.

+

Explanation

+

New definitions

+

New Definition I: Runtime Optional Positive Integer

+

The Runtime optional positive integer is a signed 64-bit value. Positive values in the range of [0..2³²) represent corresponding unsigned 32-bit values. The value of -1 represents a non-existing value (an absent value). All other values are invalid.

+

New Definition II: Runtime Optional Pointer-Size

+

The runtime optional pointer-size has exactly the same definition as runtime pointer-size (Definition 216) with the value of 2⁶⁴-1 representing a non-existing value (an absent value).

+

Changes to host functions

+

ext_storage_get

+

The function is deprecated. Users are encouraged to use ext_storage_read_version_2 instead.

+

ext_storage_read

+

The new version 2 is introduced, deprecating ext_storage_read_version_1. The new signature is

+
(func $ext_storage_read_version_2
+    (param $key i64) (param $value_out i64) (param $value_offset i32) (result i64))
+
+
Arguments
+ +
Result
+

The result is an optional positive integer (New Definition I), representing either the full length of the value in storage or the absence of such a value in storage.

+
Changes
+

The logic of the function is unchanged since the previous version. Only the result representation has changed.

+

ext_storage_clear_prefix

+

The new version 3 is introduced, deprecating ext_storage_clear_prefix_version_2. The new signature is

+
(func $ext_storage_clear_prefix_version_3
+    (param $maybe_prefix i64) (param $maybe_limit i64) (param $maybe_cursor_in i64)
+    (param $maybe_cursor_out i64) (param $backend i32) (param $unique i32) (param $loops i32)
+    (result i32))
+
+
Arguments
+ +
Result
+

The result represents the length of the continuation cursor which was written to the buffer provided in maybe_cursor_out. A zero value represents the absence of such a cursor and no need for continuation (the prefix has been completely cleared). If the buffer is not large enough to accommodate the cursor, the latter will be truncated, but the full length of the cursor will always be returned.

+
Changes
+

The new version adopts PPP#7, hence the significant change in the function interface with respect to the previous version. The reasoning for such a change was provided in the original proposal discussion.

+

ext_storage_root

+

The new version 3 is introduced, deprecating ext_storage_root_version_2. The signature is

+
(func $ext_storage_root_version_3
+    (param $out i64) (result i32))
+
+
Arguments
+ +
Results
+

The result is the length of the output stored in the buffer provided in out. If the buffer is not large enough to accommodate the data, the latter will be truncated, but the full length of the output data will always be returned.

+
Changes
+

The new version adopts PPP#6 deprecating the argument that used to represent the storage version.

+

ext_storage_next_key

+

The new version 2 is introduced, deprecating ext_storage_next_key_version_1. The signature is

+
(func $ext_storage_next_key_version_2
+    (param $key_in i64) (param $key_out i64) (result i32))
+
+
Changes
+

The logic of the function is unchanged since the previous version. The signature has changed to align with the new memory allocation strategy.

+
Arguments
+ +
Result
+

The result is the length of the output key, or zero if no next key was found. If the buffer provided in key_out is not large enough to accommodate the data, the latter will be truncated, but the full length of the output data will always be returned.

+

ext_default_child_storage_get

+

The function is deprecated. Users are encouraged to use ext_default_child_storage_read_version_2 instead.

+

ext_default_child_storage_read

+

The new version 2 is introduced, deprecating ext_default_child_storage_read_version_1. The new signature is

+
(func $ext_storage_read_version_2
+    (param $storage_key i64) (param $key i64) (param $value_out i64) (param $value_offset i32)
+    (result i64))
+
+
Arguments
+ +
Result
+

The result is an optional positive integer (New Definition I), representing either the full length of the value in storage or the absence of such a value in storage.

+
Changes
+

The logic of the function is unchanged since the previous version. Only the result representation has changed.

+

ext_default_child_storage_storage_kill

+

The new version 4 is introduced, deprecating ext_default_child_storage_storage_kill_version_3. The new signature is

+
(func $ext_default_child_storage_storage_kill_version_4
+    (param $storage_key i64) (param $maybe_limit i64) (param $maybe_cursor_in i64)
+    (param $maybe_cursor_out i64) (param $backend i32) (param $unique i32) (param $loops i32)
+    (result i32))
+
+
Arguments
+ +
Result
+

The result represents the length of the continuation cursor which was written to the buffer provided in maybe_cursor_out. A zero value represents the absence of such a cursor and no need for continuation (the prefix has been completely cleared). If the buffer is not large enough to accommodate the cursor, the latter will be truncated, but the full length of the cursor will always be returned.

+
Changes
+

The new version adopts PPP#7, hence the significant change in the function interface with respect to the previous version. The reasoning for such a change was provided in the original proposal discussion.

+

ext_default_child_storage_clear_prefix

+

The new version 3 is introduced, deprecating ext_default_child_storage_clear_prefix_version_2. The new signature is

+
(func $ext_default_child_storage_clear_prefix_version_3
+    (param $storage_key i64) (param $prefix i64) (param $maybe_limit i64)
+    (param $maybe_cursor_in i64) (param $maybe_cursor_out i64) (param $backend i32)
+    (param $unique i32) (param $loops i32) (result i32))
+
+
Arguments
+ +
Result
+

The result represents the length of the continuation cursor which was written to the buffer provided in maybe_cursor_out. A zero value represents the absence of such a cursor and no need for continuation (the prefix has been completely cleared). If the buffer is not large enough to accommodate the cursor, the latter will be truncated, but the full length of the cursor will always be returned.

+
Changes
+

The new version adopts PPP#7, hence the significant change in the function interface with respect to the previous version. The reasoning for such a change was provided in the original proposal discussion.

+

ext_default_child_storage_root

+

The new version 3 is introduced, deprecating ext_default_child_storage_root_version_2. The signature is

+
(func $ext_default_child_storage_root_version_3
+    (param $storage_key i64) (param $out i64) (result i32))
+
+
Arguments
+ +
Results
+

The result is the length of the output stored in the buffer provided in out. If the buffer is not large enough to accommodate the data, the latter will be truncated, but the full length of the output data will always be returned.

+
Changes
+

The new version adopts PPP#6 deprecating the argument that used to represent the storage version.

+

ext_default_child_storage_next_key

+

The new version 2 is introduced, deprecating ext_default_child_storage_next_key_version_1. The signature is

+
(func $ext_default_child_storage_next_key_version_2
+    (param $storage_key i64) (param $key_in i64) (param $key_out i64) (result i32))
+
+
Arguments
+ +
Result
+

The result is the length of the output key, or zero if no next key was found. If the buffer provided in key_out is not large enough to accommodate the data, the latter will be truncated, but the full length of the output data will always be returned.

+
Changes
+

The logic of the function is unchanged since the previous version. The signature has changed to align with the new memory allocation strategy.

+

ext_trie_{blake2|keccak}_256_[ordered_]root

+

The following functions share the same signatures and set of changes:

+ +

For the aforementioned functions, versions 3 were introduced, and the corresponding versions 2 were deprecated. The signature is:

+
(func $ext_trie_{blake2|keccak}_256_[ordered_]root_version_3
+    (param $input i64) (param $version i32) (param $out i32))
+
+
Arguments
+ +
Changes
+

The logic of the function is unchanged since the previous version. The signature has changed to align with the new memory allocation strategy.

+

ext_misc_runtime_version

+

The new version 2 is introduced, deprecating ext_default_child_storage_next_key_version_1. The signature is

+
(func $ext_misc_runtime_version_version_2
+    (param $wasm i64) (param $out i64) (result i64))
+
+
Arguments
+ +
Result
+

The result is an optional positive integer (New Definition I) representing the length of the output data. If the buffer is not large enough to accommodate the data, the latter will be truncated, but the full length of the output data will always be returned. An absent value represents the absence of the version information in the Wasm blob or a failure to read one.

+
Changes
+

The logic of the function is unchanged since the previous version. The signature has changed to align with the new memory allocation strategy.

+

ext_crypto_{ed25519|sr25519|ecdsa}_public_keys

+

The following functions are deprecated:

+ +

Users are encouraged to use the new *_num_public_keys and *_public_key counterparts.

+

ext_crypto_{ed25519|sr25519|ecdsa}_num_public_keys

+

New functions, all sharing the same signature and logic, are introduced:

+ +

The signature is:

+
(func $ext_crypto_{ed25519|sr25519|ecdsa}_num_public_keys
+    (param $id i32) (result i32))
+
+
Arguments
+ +
Result
+

The result represents a (possibly zero) number of keys of the given type known to the keystore.

+

ext_crypto_{ed25519|sr25519|ecdsa}_public_key

+

New functions, all sharing the same signature and logic, are introduced:

+ +

The signature is:

+
(func $ext_crypto_{ed25519|sr25519|ecdsa}_public_key
+    (param $id i32) (param $index i32) (param $out))
+
+
Arguments
+ +

ext_crypto_{ed25519|sr25519|ecdsa}_generate

+

The following functions share the same signatures and set of changes:

+ +

For the aforementioned functions, versions 2 are introduced, and the corresponding versions 1 are deprecated. The signature is:

+
(func $ext_crypto_{ed25519|sr25519|ecdsa}_generate_version_2
+    (param $id i32) (param $seed i64) (param $out i32))
+
+
Arguments
+ +
Changes
+

The logic of the functions is unchanged since the previous version. The signature has changed to align with the new memory allocation strategy.

+

ext_crypto_{ed25519|sr25519|ecdsa}_sign[_prehashed]

+

The following functions share the same signatures and set of changes:

+ +

For the aforementioned functions, versions 2 are introduced, and the corresponding versions 1 are deprecated. The signature is:

+
(func $ext_crypto_{ed25519|sr25519|ecdsa}_sign{_prehashed|}_version_2
+    (param $id i32) (param $pub_key i32) (param $msg i64) (param $out i64) (result i64))
+
+
Arguments
+ +
Result
+

The function returns 0 on success. On error, -1 is returned and the output buffer should be considered uninitialized.

+
Changes
+

The logic of the functions is unchanged since the previous version. The signature has changed to align with the new memory allocation strategy.

+

ext_crypto_secp256k1_ecdsa_recover[_compressed]

+

The following functions share the same signatures and set of changes:

+ +

For the aforementioned functions, versions 3 are introduced, and the corresponding versions 2 are deprecated. The signature is:

+
(func $ext_crypto_secp256k1_ecdsa_recover\[_compressed]_version_3
+    (param $sig i32) (param $msg i32) (param $out i32) (result i64))
+
+
Arguments
+ +
Result
+

The function returns 0 on success. On error, it returns a negative ECDSA verification error code, where -1 stands for incorrect R or S, -2 stands for invalid V, and -3 stands for invalid signature.

+
Changes
+

The signature has changed to align with the new memory allocation strategy. The return error encoding, defined under Definition 221, is changed to promote the unification of host function result reporting (zero and positive values are for success, and the negative values are for failure codes).

+

ext_hashing_{keccak|sha2|blake2|twox}_

+

The following functions share the same signatures and set of changes:

+ +

For the aforementioned functions, versions 2 are introduced, and the corresponding versions 1 are deprecated. The signature is:

+
(func $ext_hashing_{keccak|sha2|blake2|twox}_{64|128|256|512}_version_2
+    (param $data i64) (param $out i32))
+
+
Arguments
+ +
Changes
+

The logic of the functions is unchanged since the previous version. The signature has changed to align with the new memory allocation strategy.

+

ext_offchain_submit_transaction

+

The new version 2 is introduced, deprecating ext_offchain_submit_transaction_version_1. The signature is unchanged.

+
(func $ext_offchain_submit_transaction_version_2
+    (param $data i64) (result i64))
+
+
Arguments
+ +
Result
+

The result is 0 for success or -1 for failure.

+
Changes
+

The logic and the signature of the function are unchanged since the previous version. The only change is the interpretation of the result value to avoid an unneeded allocation and promote the unification of host function result reporting (zero and positive values are for success, and the negative values are for failure codes).

+

ext_offchain_network_state

+

The function is deprecated. Users are encouraged to use ext_offchain_network_peer_id_version_1 instead.

+

ext_offchain_network_peer_id

+

A new function is introduced. The signature is

+
(func $ext_offchain_submit_transaction_version_2
+    (param $out i32) (result i64))
+
+
Arguments
+ +
Result
+

The result is 0 for success or -1 for failure.

+

ext_offchain_random_seed

+

The new version 2 is introduced, deprecating ext_offchain_random_seed_version_1. The signature is unchanged.

+
(func $ext_offchain_random_seed_version_2
+    (param $out i32))
+
+
Arguments
+ +
Changes
+

The logic of the functions is unchanged since the previous version. The signature has changed to align with the new memory allocation strategy and promote the unification of host function result returning (zero and positive values are for success, and the negative values are for failure codes).

+

ext_offchain_local_storage_get

+

The function is deprecated. Users are encouraged to use ext_offchain_local_storage_read_version_1 instead.

+

ext_offchain_local_storage_read

+

A new function is introduced. The signature is

+
(func $ext_offchain_local_storage_read_version_1
+    (param $kind i32) (param $key i64) (param $value_out i64) (param $offset i32) (result i64))
+
+
Arguments
+ +
Result
+

The result is an optional positive integer (New Definition I), representing either the full length of the value in storage or the absence of such a value in storage.

+

ext_offchain_http_request_start

+

The new version 2 is introduced, deprecating ext_offchain_http_request_start_version_1. The signature is unchanged.

+
(func $ext_offchain_http_request_start_version_2
+    (param $method i64) (param $uri i64) (param $meta i64) (result i64))
+
+
Arguments
+

method is a pointer-size (Definition 216) to the HTTP method. Possible values are “GET” and “POST”; +uri is a pointer-size (Definition 216) to the URI; +meta is a future-reserved field containing additional, SCALE-encoded parameters. Currently, an empty array should be passed.

+
Result
+

On success, a positive request identifier is returned. On error, -1 is returned.

+
Changes
+

The logic and the signature of the function are unchanged since the previous version. The only change is the interpretation of the result value to avoid an unneeded allocation and promote the unification of host function result returning (zero and positive values are for success, and the negative values are for failure codes).

+

ext_offchain_http_request_add_header

+

The new version 2 is introduced, deprecating ext_offchain_http_request_add_header_version_1. The signature is unchanged.

+
(func $ext_offchain_http_request_add_header_version_2
+    (param $request_id i32) (param $name i64) (param $value i64) (result i64))
+
+
Arguments
+ +
Result
+

The result is 0 for success or -1 for failure.

+
Changes
+

The logic and the signature of the function are unchanged since the previous version. The only change is the interpretation of the result value to avoid an unneeded allocation and promote the unification of host function result returning (zero and positive values are for success, and the negative values are for failure codes).

+

ext_offchain_http_request_write_body

+

The new version 2 is introduced, deprecating ext_offchain_http_request_write_body_version_1. The signature is unchanged.

+
(func $ext_offchain_http_request_write_body_version_2
+    (param $request_id i32) (param $chunk i64) (param $deadline i64) (result i64))
+
+
Arguments
+ +
Result
+

On success, 0 is returned. On failure, a negative error code is returned, where -1 denotes the deadline was reached, -2 denotes that an I/O error occurred, and -3 denotes that the request ID provided was invalid.

+
Changes
+

The logic and the signature of the function are unchanged since the previous version. The only change is the interpretation of the result value to avoid an unneeded allocation and promote the unification of host function result returning (zero and positive values are for success, and the negative values are for failure codes).

+

ext_offchain_http_request_wait

+

The new version 2 is introduced, deprecating ext_offchain_http_request_wait_version_1. The signature is:

+
(func $ext_offchain_http_request_wait_version_2
+    (param $ids i64) (param $deadline i64) (param $out i64))
+
+
Arguments
+ +
Changes
+

The logic of the functions is unchanged since the previous version. The signature has changed to align with the new memory allocation strategy.

+

ext_offchain_http_response_read_body

+

The new version 2 is introduced, deprecating ext_offchain_http_response_read_body_version_1. The signature is unchanged.

+
(func $ext_offchain_http_response_read_body_version_2
+    (param $request_id i32) (param $buffer i64) (param $deadline i64) (result i64))
+
+
Arguments
+ +
Result
+

On success, the number of bytes written to the buffer is returned. A value of 0 means the entire response was consumed and no further calls to the function are needed for the provided request ID. On failure, a negative error code is returned, where -1 denotes the deadline was reached, -2 denotes that an I/O error occurred, and -3 denotes that the request ID provided was invalid.

+
Changes
+

The logic and the signature of the function are unchanged since the previous version. The only change is the interpretation of the result value to avoid an unneeded allocation and promote the unification of host function result returning (zero and positive values are for success, and the negative values are for failure codes).

+

ext_allocator_

+

The functions are deprecated and must not be used in new code.

+

ext_input_read

+

A new function is introduced. The signature is

+
(func $ext_input_read_version_1
+    (param $buffer i64))
+
+
Arguments
+ +

Other changes

+

Currently, all runtime entrypoints have the following identical Wasm function signatures:

+
(func $runtime_entrypoint (param $data i32) (param $len i32) (result i64))
+
+

After this RFC is implemented, such entrypoints are still supported, but considered deprecated. New entrypoints must have the following signature:

+
(func $runtime_entrypoint (param $len i32) (result i64))
+
+

A runtime function called through such an entrypoint gets the length of SCALE-encoded input data as its only argument. After that, the function must allocate exactly the amount of bytes it is requested, and call the ext_input_read host function to obtain the encoded input data.

(source)

Table of Contents