Implement cumulus StorageWeightReclaim as wrapping transaction extension +...
Implement cumulus StorageWeightReclaim as wrapping transaction extension + frame system ReclaimWeight (#6140) (rebasing of https://github.com/paritytech/polkadot-sdk/pull/5234) ## Issues: * Transaction extensions have weights and refund weight. So the reclaiming of unused weight must happen last in the transaction extension pipeline. Currently it is inside `CheckWeight`. * cumulus storage weight reclaim transaction extension misses the proof size of logic happening prior to itself. ## Done: * a new storage `ExtrinsicWeightReclaimed` in frame-system. Any logic which attempts to do some reclaim must use this storage to avoid double reclaim. * a new function `reclaim_weight` in frame-system pallet: info and post info in arguments, read the already reclaimed weight, calculate the new unused weight from info and post info. do the more accurate reclaim if higher. * `CheckWeight` is unchanged and still reclaim the weight in post dispatch * `ReclaimWeight` is a new transaction extension in frame system. For solo chains it must be used last in the transactino extension pipeline. It does the final most accurate reclaim * `StorageWeightReclaim` is moved from cumulus primitives into its own pallet (in order to define benchmark) and is changed into a wrapping transaction extension. It does the recording of proof size and does the reclaim using this recording and the info and post info. So parachains don't need to use `ReclaimWeight`. But also if they use it, there is no bug. ```rust /// The TransactionExtension to the basic transaction logic. pub type TxExtension = cumulus_pallet_weight_reclaim::StorageWeightReclaim< Runtime, ( frame_system::CheckNonZeroSender<Runtime>, frame_system::CheckSpecVersion<Runtime>, frame_system::CheckTxVersion<Runtime>, frame_system::CheckGenesis<Runtime>, frame_system::CheckEra<Runtime>, frame_system::CheckNonce<Runtime>, frame_system::CheckWeight<Runtime>, pallet_transaction_payment::ChargeTransactionPayment<Runtime>, BridgeRejectObsoleteHeadersAndMessages, (bridge_to_rococo_config::OnBridgeHubWestendRefundBridgeHubRococoMessages,), frame_metadata_hash_extension::CheckMetadataHash<Runtime>, ), >; ``` --------- Co-authored-by:GitHub Action <action@github.com> Co-authored-by:
georgepisaltu <52418509+georgepisaltu@users.noreply.github.com> Co-authored-by:
Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> Co-authored-by:
Sebastian Kunert <skunert49@gmail.com> Co-authored-by: command-bot <>
parent
b5a5ac44
Showing
- .github/workflows/runtimes-matrix.json 1 addition, 1 deletion.github/workflows/runtimes-matrix.json
- Cargo.lock 35 additions, 15 deletionsCargo.lock
- Cargo.toml 2 additions, 0 deletionsCargo.toml
- cumulus/pallets/weight-reclaim/Cargo.toml 63 additions, 0 deletionscumulus/pallets/weight-reclaim/Cargo.toml
- cumulus/pallets/weight-reclaim/src/benchmarks.rs 71 additions, 0 deletionscumulus/pallets/weight-reclaim/src/benchmarks.rs
- cumulus/pallets/weight-reclaim/src/lib.rs 311 additions, 0 deletionscumulus/pallets/weight-reclaim/src/lib.rs
- cumulus/pallets/weight-reclaim/src/tests.rs 1050 additions, 0 deletionscumulus/pallets/weight-reclaim/src/tests.rs
- cumulus/pallets/weight-reclaim/src/weights.rs 74 additions, 0 deletionscumulus/pallets/weight-reclaim/src/weights.rs
- cumulus/parachains/runtimes/assets/asset-hub-rococo/Cargo.toml 4 additions, 2 deletions...us/parachains/runtimes/assets/asset-hub-rococo/Cargo.toml
- cumulus/parachains/runtimes/assets/asset-hub-rococo/src/lib.rs 20 additions, 12 deletions...us/parachains/runtimes/assets/asset-hub-rococo/src/lib.rs
- cumulus/parachains/runtimes/assets/asset-hub-rococo/src/weights/cumulus_pallet_weight_reclaim.rs 67 additions, 0 deletions...t-hub-rococo/src/weights/cumulus_pallet_weight_reclaim.rs
- cumulus/parachains/runtimes/assets/asset-hub-rococo/src/weights/frame_system_extensions.rs 54 additions, 33 deletions...s/asset-hub-rococo/src/weights/frame_system_extensions.rs
- cumulus/parachains/runtimes/assets/asset-hub-rococo/src/weights/mod.rs 1 addition, 0 deletions...hains/runtimes/assets/asset-hub-rococo/src/weights/mod.rs
- cumulus/parachains/runtimes/assets/asset-hub-westend/Cargo.toml 4 additions, 2 deletions...s/parachains/runtimes/assets/asset-hub-westend/Cargo.toml
- cumulus/parachains/runtimes/assets/asset-hub-westend/src/lib.rs 21 additions, 13 deletions...s/parachains/runtimes/assets/asset-hub-westend/src/lib.rs
- cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/cumulus_pallet_weight_reclaim.rs 67 additions, 0 deletions...-hub-westend/src/weights/cumulus_pallet_weight_reclaim.rs
- cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/frame_system_extensions.rs 54 additions, 33 deletions.../asset-hub-westend/src/weights/frame_system_extensions.rs
- cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/mod.rs 1 addition, 0 deletions...ains/runtimes/assets/asset-hub-westend/src/weights/mod.rs
- cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/Cargo.toml 4 additions, 2 deletions...achains/runtimes/bridge-hubs/bridge-hub-rococo/Cargo.toml
- cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/lib.rs 61 additions, 50 deletions...achains/runtimes/bridge-hubs/bridge-hub-rococo/src/lib.rs
Please register or sign in to comment