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
@@ -0,0 +1,46 @@
[package]
name = "cumulus-primitives-storage-weight-reclaim"
version = "1.0.0"
authors.workspace = true
edition.workspace = true
description = "Utilities to reclaim storage weight."
license = "Apache-2.0"
[lints]
workspace = true
[dependencies]
codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive"] }
log = { workspace = true }
scale-info = { version = "2.10.0", default-features = false, features = ["derive"] }
frame-support = { path = "../../../substrate/frame/support", default-features = false }
frame-system = { path = "../../../substrate/frame/system", default-features = false }
sp-runtime = { path = "../../../substrate/primitives/runtime", default-features = false }
sp-std = { path = "../../../substrate/primitives/std", default-features = false }
cumulus-primitives-core = { path = "../../primitives/core", default-features = false }
cumulus-primitives-proof-size-hostfunction = { path = "../../primitives/proof-size-hostfunction", default-features = false }
docify = "0.2.7"
[dev-dependencies]
sp-trie = { path = "../../../substrate/primitives/trie", default-features = false }
sp-io = { path = "../../../substrate/primitives/io", default-features = false }
cumulus-test-runtime = { path = "../../test/runtime" }
[features]
default = ["std"]
std = [
"codec/std",
"cumulus-primitives-core/std",
"cumulus-primitives-proof-size-hostfunction/std",
"frame-support/std",
"frame-system/std",
"log/std",
"scale-info/std",
"sp-io/std",
"sp-runtime/std",
"sp-std/std",
"sp-trie/std",
]