-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Implement cumulus StorageWeightReclaim as wrapping transaction extension + frame system ReclaimWeight #6140
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 30 commits
Commits
Show all changes
84 commits
Select commit
Hold shift + click to select a range
d252ce1
storage weight reclaim
gui1117 670add6
move prdoc
gui1117 d1e480a
fmt
gui1117 06903c8
use new extension for bridge hub rococo
gui1117 9500cd1
fix macro
gui1117 9bc4f6c
remove unnecessary deprecated
gui1117 c316f8a
umbrella
gui1117 6e7b072
use in template
gui1117 b9f00fc
Merge branch 'master' into gui-storage-proof-size-reclaim-more-accurate
gui1117 7c777db
fix template
gui1117 f336a34
prdoc semver
gui1117 f40892f
complete wrapper including bare stuff
gui1117 337d5c8
coordinate refunds with a storage
gui1117 4740554
Merge remote-tracking branch 'origin/master' into gui-storage-proof-s…
gui1117 643cfda
do not change check weight position
gui1117 52cc2aa
fmt
gui1117 f4f5e19
remove forgotten dbg
gui1117 cf2275f
fix benchmark
gui1117 7a001e8
Merge branch 'master' into gui-storage-proof-size-reclaim-more-accurate
gui1117 9473523
Update from gui1117 running command 'bench --runtime asset-hub-rococo…
actions-user ac6ec39
Update from gui1117 running command 'bench --runtime asset-hub-westen…
actions-user b45868c
link to correct weights
gui1117 f8028e7
add system weight reclaim for solo and relay chains
gui1117 ae0f0b7
fixes
gui1117 a6d4bd1
fix WeightInfo usages
gui1117 5b7d968
fix CI
gui1117 eebb5c7
Update from gui1117 running command 'bench --pallet frame_system --cl…
actions-user 906f150
Revert "Update from gui1117 running command 'bench --pallet frame_sys…
gui1117 e5b8bf6
fix test
gui1117 ba1b3bf
Update from gui1117 running command 'bench --pallet frame_system_exte…
actions-user be6b34e
remove unused
gui1117 bc625fc
better trace and some comment
gui1117 f792821
use weight reclaim everywhere
gui1117 1704d70
fmt
gui1117 10b0ef0
add tests
gui1117 5e8cae0
Update cumulus/pallets/weight-reclaim/src/lib.rs
gui1117 a0a0589
Update substrate/frame/system/src/lib.rs
gui1117 5322297
more explicit names
gui1117 472d63c
single operation on weight
gui1117 597fde4
return more accurate unspent from storage reclaim tx ext
gui1117 1ad6e56
Keep accrue when node proof size is bigger: https://github.com/parity…
gui1117 898caa6
outdated comment
gui1117 363f7d3
fix post info + tests
gui1117 fee7274
Update prdoc/pr_6140.prdoc
gui1117 17decb9
Update cumulus/pallets/weight-reclaim/src/benchmarks.rs
gui1117 79addc7
refactor
gui1117 d70e552
renames and defensive
gui1117 22dc356
better dbg
gui1117 e12b038
Merge remote-tracking branch 'origin/master' into gui-storage-proof-s…
gui1117 48a2450
fix master merge issue
gui1117 1a9aeee
fix merge + fix some import + fmt
gui1117 144fd7e
Merge branch 'master' into gui-storage-proof-size-reclaim-more-accurate
gui1117 3516356
fix master merge
gui1117 1c08968
necessary changes to cargo.lock
gui1117 204f806
prdoc
gui1117 33df168
Update cumulus/pallets/weight-reclaim/src/lib.rs
gui1117 3c8c0e7
Put the missing from node logic as part of the reclaim in ExtrinsicWe…
gui1117 cd9e85c
Merge remote-tracking branch 'origin/master' into gui-storage-proof-s…
gui1117 ed62dff
update lock
gui1117 55610fb
".git/.scripts/commands/bench-all/bench-all.sh" --pallet=frame_system…
62ab3a7
".git/.scripts/commands/bench-all/bench-all.sh" --pallet=frame_system…
298123a
".git/.scripts/commands/bench-all/bench-all.sh" --pallet=cumulus_pall…
594dde1
".git/.scripts/commands/bench-all/bench-all.sh" --pallet=cumulus_pall…
22c1e0f
".git/.scripts/commands/bench-all/bench-all.sh" --pallet=frame_system…
efa1765
".git/.scripts/commands/bench-all/bench-all.sh" --pallet=cumulus_pall…
5ec3aee
".git/.scripts/commands/bench-all/bench-all.sh" --pallet=frame_system…
1e4cc42
".git/.scripts/commands/bench-all/bench-all.sh" --pallet=cumulus_pall…
84e2688
".git/.scripts/commands/bench-all/bench-all.sh" --pallet=frame_system…
d078a2f
".git/.scripts/commands/bench-all/bench-all.sh" --pallet=cumulus_pall…
df1b1f1
Merge branch 'master' of https://github.com/paritytech/polkadot-sdk i…
63ff091
".git/.scripts/commands/bench-all/bench-all.sh" --pallet=cumulus_pall…
25eb5d3
".git/.scripts/commands/bench-all/bench-all.sh" --pallet=cumulus_pall…
830507d
".git/.scripts/commands/bench-all/bench-all.sh" --pallet=cumulus_pall…
3af64d3
fmt
gui1117 78f19e4
taplo
gui1117 af19a4e
Merge branch 'master' into gui-storage-proof-size-reclaim-more-accurate
gui1117 f83ac09
".git/.scripts/commands/bench-all/bench-all.sh" --pallet=cumulus_pall…
dc92a6b
doc + test
gui1117 dd1014f
add StorageWeightReclaim to metadata
gui1117 50b562d
semver
gui1117 b1946cd
Merge branch 'master' into gui-storage-proof-size-reclaim-more-accurate
gui1117 a8f7941
taplo?
gui1117 3b3503c
Merge branch 'master' into gui-storage-proof-size-reclaim-more-accurate
gui1117 1f498b9
fix master merge
gui1117 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,63 @@ | ||
| [package] | ||
| name = "cumulus-pallet-weight-reclaim" | ||
| version = "1.0.0" | ||
| authors.workspace = true | ||
| edition.workspace = true | ||
| license = "Apache-2.0" | ||
| homepage.workspace = true | ||
| repository.workspace = true | ||
| description = "pallet and transaction extensions for accurate proof size reclaim" | ||
|
|
||
| [lints] | ||
| workspace = true | ||
|
|
||
| [package.metadata.docs.rs] | ||
| targets = ["x86_64-unknown-linux-gnu"] | ||
|
|
||
| [dependencies] | ||
| # Substrate dependencies | ||
| sp-runtime = { workspace = true } | ||
| sp-io = { workspace = true } | ||
| sp-trie = { workspace = true } | ||
|
|
||
| frame-support = { workspace = true } | ||
| frame-system = { workspace = true } | ||
| frame-benchmarking = { optional = true, workspace = true } | ||
| cumulus-primitives-storage-weight-reclaim = { workspace = true } | ||
|
|
||
| # Other dependencies | ||
| codec = { features = ["derive"], workspace = true } | ||
| scale-info = { features = ["derive"], workspace = true } | ||
| log = { workspace = true, default-features = true } | ||
| derivative = { features = ["use_core"], workspace = true } | ||
| docify = { workspace = true } | ||
|
|
||
| [dev-dependencies] | ||
| cumulus-primitives-proof-size-hostfunction = { workspace = true } | ||
|
|
||
| [features] | ||
| default = ["std"] | ||
| std = [ | ||
| "codec/std", | ||
| "cumulus-primitives-proof-size-hostfunction/std", | ||
| "cumulus-primitives-storage-weight-reclaim/std", | ||
| "frame-benchmarking?/std", | ||
| "frame-support/std", | ||
| "frame-system/std", | ||
| "log/std", | ||
| "scale-info/std", | ||
| "sp-io/std", | ||
| "sp-runtime/std", | ||
| "sp-trie/std", | ||
| ] | ||
| runtime-benchmarks = [ | ||
| "frame-benchmarking/runtime-benchmarks", | ||
| "frame-support/runtime-benchmarks", | ||
| "frame-system/runtime-benchmarks", | ||
| "sp-runtime/runtime-benchmarks", | ||
| ] | ||
| try-runtime = [ | ||
| "frame-support/try-runtime", | ||
| "frame-system/try-runtime", | ||
| "sp-runtime/try-runtime", | ||
| ] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,73 @@ | ||
| // Copyright (C) Parity Technologies (UK) Ltd. | ||
| // This file is part of Cumulus. | ||
|
|
||
| // Cumulus is free software: you can redistribute it and/or modify | ||
| // it under the terms of the GNU General Public License as published by | ||
| // the Free Software Foundation, either version 3 of the License, or | ||
| // (at your option) any later version. | ||
|
|
||
| // Cumulus is distributed in the hope that it will be useful, | ||
| // but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| // GNU General Public License for more details. | ||
|
|
||
| // You should have received a copy of the GNU General Public License | ||
| // along with Cumulus. If not, see <http://www.gnu.org/licenses/>. | ||
|
|
||
| #![cfg(feature = "runtime-benchmarks")] | ||
|
|
||
| use super::*; | ||
| use frame_support::pallet_prelude::{DispatchClass, Pays}; | ||
| use frame_system::RawOrigin; | ||
| use sp_runtime::traits::{AsTransactionAuthorizedOrigin, DispatchTransaction}; | ||
|
|
||
| #[frame_benchmarking::v2::benchmarks( | ||
| where T: Send + Sync, | ||
| <T as frame_system::Config>::RuntimeCall: | ||
| Dispatchable<Info = DispatchInfo, PostInfo = PostDispatchInfo>, | ||
| <T as frame_system::Config>::RuntimeOrigin: AsTransactionAuthorizedOrigin, | ||
| )] | ||
| mod bench { | ||
| use super::*; | ||
| use frame_benchmarking::impl_test_function; | ||
|
|
||
| #[benchmark] | ||
| fn storage_weight_reclaim() -> Result<(), frame_benchmarking::BenchmarkError> { | ||
| let ext = StorageWeightReclaim::<T, ()>::new(()); | ||
|
|
||
| let origin = RawOrigin::Root.into(); | ||
| let call = T::RuntimeCall::from(frame_system::Call::remark { remark: alloc::vec![] }); | ||
|
|
||
| let overestimate = 10_000; | ||
| let info = DispatchInfo { | ||
| call_weight: Weight::zero().add_proof_size(overestimate), | ||
| extension_weight: Weight::zero(), | ||
| class: DispatchClass::Normal, | ||
| pays_fee: Pays::No, | ||
| }; | ||
|
|
||
| let post_info = PostDispatchInfo { actual_weight: None, pays_fee: Pays::No }; | ||
|
|
||
| let mut block_weight = frame_system::ConsumedWeight::default(); | ||
| block_weight.accrue(Weight::from_parts(0, overestimate), info.class); | ||
|
|
||
| frame_system::BlockWeight::<T>::put(block_weight); | ||
|
|
||
| #[block] | ||
| { | ||
| assert!(ext.test_run(origin, &call, &info, 0, |_| Ok(post_info)).unwrap().is_ok()); | ||
| } | ||
|
|
||
| let final_block_proof_size = | ||
| frame_system::BlockWeight::<T>::get().get(info.class).proof_size(); | ||
|
|
||
| assert!( | ||
| final_block_proof_size < overestimate, | ||
| "The proof size measured should be less than {overestimate}" | ||
| ); | ||
|
|
||
| Ok(()) | ||
| } | ||
|
|
||
| impl_benchmark_test_suite!(Pallet, crate::tests::setup_test_ext_default(), crate::tests::Test); | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.