PoV Reclaim Runtime Side (#3002)

# Runtime side for PoV Reclaim

## Implementation Overview
- Hostfunction to fetch the storage proof size has been added to the
PVF. It uses the size tracking recorder that was introduced in my
previous PR.
- Mechanisms to use the reclaim HostFunction have been introduced.
- 1. A SignedExtension that checks the node-reported proof size before
and after application of an extrinsic. Then it reclaims the difference.
- 2. A manual helper to make reclaiming easier when manual interaction
is required, for example in `on_idle` or other hooks.
- In order to utilize the manual reclaiming, I modified `WeightMeter` to
support the reduction of consumed weight, at least for storage proof
size.

## How to use
To enable the general functionality for a parachain:
1. Add the SignedExtension to your parachain runtime. 
2. Provide the HostFunction to the node
3. Enable proof recording during block import

## TODO
- [x] PRDoc

---------

Co-authored-by: Dmitry Markin <dmitry@markin.tech>
Co-authored-by: Davide Galassi <davxy@datawok.net>
Co-authored-by: Bastian Köcher <git@kchr.de>
This commit is contained in:
Sebastian Kunert
2024-02-23 15:09:49 +01:00
committed by GitHub
parent 5fc6d67be0
commit 3386377b0f
25 changed files with 875 additions and 29 deletions
Generated
+23
View File
@@ -4047,6 +4047,25 @@ dependencies = [
"sp-trie",
]
[[package]]
name = "cumulus-primitives-storage-weight-reclaim"
version = "1.0.0"
dependencies = [
"cumulus-primitives-core",
"cumulus-primitives-proof-size-hostfunction",
"cumulus-test-runtime",
"docify",
"frame-support",
"frame-system",
"log",
"parity-scale-codec",
"scale-info",
"sp-io",
"sp-runtime",
"sp-std 14.0.0",
"sp-trie",
]
[[package]]
name = "cumulus-primitives-timestamp"
version = "0.7.0"
@@ -4209,6 +4228,7 @@ dependencies = [
"cumulus-primitives-core",
"cumulus-primitives-parachain-inherent",
"cumulus-primitives-proof-size-hostfunction",
"cumulus-primitives-storage-weight-reclaim",
"cumulus-test-relay-sproof-builder",
"cumulus-test-runtime",
"cumulus-test-service",
@@ -4253,6 +4273,7 @@ version = "0.1.0"
dependencies = [
"cumulus-pallet-parachain-system",
"cumulus-primitives-core",
"cumulus-primitives-storage-weight-reclaim",
"frame-executive",
"frame-support",
"frame-system",
@@ -4295,6 +4316,7 @@ dependencies = [
"cumulus-client-service",
"cumulus-pallet-parachain-system",
"cumulus-primitives-core",
"cumulus-primitives-storage-weight-reclaim",
"cumulus-relay-chain-inprocess-interface",
"cumulus-relay-chain-interface",
"cumulus-relay-chain-minimal-node",
@@ -11340,6 +11362,7 @@ dependencies = [
"cumulus-pallet-xcm",
"cumulus-pallet-xcmp-queue",
"cumulus-primitives-core",
"cumulus-primitives-storage-weight-reclaim",
"cumulus-primitives-utility",
"frame-benchmarking",
"frame-executive",