-
Notifications
You must be signed in to change notification settings - Fork 9
feat(benchmarks): add benchmarks and specific weights to all pallets #91
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 all commits
Commits
Show all changes
32 commits
Select commit
Hold shift + click to select a range
6a7e1c3
feat(benchmarks): add feature runtime-benchmarks to all pallets
clearloop 02867e3
feat(benchmark): add benchmark command to cli
clearloop 1466317
feat(spec): load spec without path
clearloop 0e3afe8
feat(cli): enable benchmark command only with feature runtime-benchmarks
clearloop d20a0a3
chore(benchmakrs): configure runtime-benchmarks features to command b…
clearloop adfda2a
chore(benchmarks): leave comments to withdraw in asset-index
clearloop d94785b
feat(committee): benchmark for extrinsic vote
clearloop 14fa3b6
feat(benchmark): benchmark for pallet local-treasury
clearloop 313d9d9
feat(benchmark): add benchmarks to pallet price-feed
clearloop 212578b
feat(benchmark): add benchmark to remote-asset-manager
clearloop fa00361
feat(benchmark): abstract benchmarks to saft-registry
clearloop ba1d0db
feat(benchmark): complete benchmarks of committee
clearloop 02b67c3
feat(weights): add weights of asset-index to runtime
clearloop 3a71256
feat(benchmark): add weights of remote-asset-registry to runtime
clearloop 5965730
feat(benchmark): add weights of local-treasury to runtime
clearloop fa70208
feat(benchmarks): add default weight for tests
clearloop df93419
chore(weights): add license to weight files
clearloop f1a4de9
feat(benchmark): add default weight to pallet committee
clearloop aa76617
feat(benchmark): add default weights to pallet price feed
clearloop 1163ed7
feat(benchmark): add default weight to pallet saft registry
clearloop f744ee6
chore(weights): add license too the weight config of pallet_saft_regi…
clearloop d374726
feat(benchmark): add default weight to pallet committee
clearloop 4dfe944
feat(price-feed): configure Chainsafe/chainlink-polkadot to price-feed
clearloop 31323ef
feat(weights): add weights to all calls
clearloop e70791c
feat(benchmark): add verification to pallet saft-registry
clearloop 0fb7d14
feat(benchmark): add verification to pallet price-feed
clearloop 1c3c6cc
feat(benchmark): add verification to pallet local-treasury
clearloop bc1dc98
feat(benchmark): add verification to pallet committee
clearloop a25b48f
feat(benchmarks): clean useless code
clearloop 93c474f
Revert "feat(benchmarks): clean useless code"
clearloop 9ae7704
perf(benchmark): remote TODOs for setting weights
clearloop b22b654
perf(benchmark): remove comments on the benchmarking of pallet-index
clearloop 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
Large diffs are not rendered by default.
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
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
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,7 @@ | ||
| // Copyright 2021 ChainSafe Systems | ||
| // SPDX-License-Identifier: LGPL-3.0-only | ||
| //! Benchmarks | ||
| //! | ||
| //! TODO: | ||
| //! | ||
| //! This pallet contains no calls currently. |
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,31 @@ | ||
| // Copyright 2021 ChainSafe Systems | ||
| // SPDX-License-Identifier: LGPL-3.0-only | ||
| use super::*; | ||
| use crate::types::{AssetAvailability, IndexAssetData}; | ||
| use frame_benchmarking::{benchmarks, whitelisted_caller}; | ||
| use frame_support::traits::Currency; | ||
| use frame_system::RawOrigin; | ||
| use xcm::v0::MultiLocation; | ||
|
|
||
| benchmarks! { | ||
| add_asset { | ||
| let asset_id = 42.into(); | ||
| let caller: T::AccountId = whitelisted_caller(); | ||
| let million = 1_000_000u32.into(); | ||
| T::IndexToken::deposit_creating(&caller, million); | ||
| }: _( | ||
| RawOrigin::Signed(caller.clone()), | ||
| asset_id, | ||
| million, | ||
| AssetAvailability::Liquid(MultiLocation::Null), | ||
| million | ||
| ) verify { | ||
| assert_eq!( | ||
| <Holdings<T>>::get(asset_id), | ||
| Some(IndexAssetData::new( | ||
| million, | ||
| AssetAvailability::Liquid(MultiLocation::Null) | ||
| )) | ||
| ); | ||
| } | ||
| } |
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
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,98 @@ | ||
| // Copyright 2021 ChainSafe Systems | ||
| // SPDX-License-Identifier: LGPL-3.0-only | ||
| use super::*; | ||
| use frame_benchmarking::{account, benchmarks, vec, whitelisted_caller, Box}; | ||
| use frame_support::{assert_noop, assert_ok, traits::Get}; | ||
| use frame_system::{Call as SystemCall, Pallet as System, RawOrigin as SystemOrigin}; | ||
|
|
||
| fn submit_proposal<T: Config>(caller: T::AccountId) -> pallet::Proposal<T> { | ||
| let action: T::Action = <SystemCall<T>>::remark(vec![0; 0]).into(); | ||
| let expected_nonce = pallet::ProposalCount::<T>::get(); | ||
| assert_ok!(<Pallet<T>>::propose( | ||
| SystemOrigin::Signed(caller).into(), | ||
| Box::new(action.clone()) | ||
| )); | ||
| pallet::Proposal::<T>::new(expected_nonce, action) | ||
| } | ||
|
|
||
| benchmarks! { | ||
| propose { | ||
| let caller: T::AccountId = whitelisted_caller(); | ||
| let proposal = submit_proposal::<T>(caller.clone()); | ||
| }: _( | ||
| SystemOrigin::Signed(caller.clone()), | ||
| Box::new(<SystemCall<T>>::remark(vec![0; 0]).into()) | ||
| ) verify { | ||
| assert!(<Pallet<T>>::get_proposal(&proposal.hash()) == Some(proposal)); | ||
| } | ||
|
|
||
| vote { | ||
| let caller: T::AccountId = whitelisted_caller(); | ||
| let proposal = submit_proposal::<T>(caller.clone()); | ||
| assert_ok!(<Pallet<T>>::add_constituent(SystemOrigin::Root.into(), caller.clone())); | ||
|
|
||
| // run to voting period | ||
| <System<T>>::set_block_number( | ||
| <System<T>>::block_number() | ||
| + <T as Config>::VotingPeriod::get() | ||
| + <T as Config>::ProposalSubmissionPeriod::get() + 1_u32.into(), | ||
| ); | ||
| }: _( | ||
| SystemOrigin::Signed(caller.clone()), | ||
| proposal.hash(), | ||
| Vote::Abstain | ||
| ) verify { | ||
| assert_eq!( | ||
| <Pallet<T>>::get_votes_for(&proposal.hash()).unwrap().votes.len(), | ||
| 1, | ||
| ); | ||
| } | ||
|
|
||
| close { | ||
| let caller: T::AccountId = whitelisted_caller(); | ||
| let proposal: pallet::Proposal<T> = submit_proposal::<T>(caller.clone()); | ||
| assert_ok!(<Pallet<T>>::add_constituent(SystemOrigin::Root.into(), caller.clone())); | ||
| let voters = ["a", "b", "c", "d", "e"]; | ||
|
|
||
| // run to voting period | ||
| <System<T>>::set_block_number(<System<T>>::block_number() + <T as Config>::VotingPeriod::get() + <T as Config>::ProposalSubmissionPeriod::get() + 1_u32.into()); | ||
|
|
||
| // generate members | ||
| for i in &voters { | ||
| let voter: T::AccountId = account(i, 0, 0); | ||
| <Members<T>>::insert(voter.clone(), MemberType::Council); | ||
|
|
||
| // vote aye | ||
| assert_ok!(<Pallet<T>>::vote( | ||
| SystemOrigin::Signed(voter).into(), | ||
| proposal.hash(), | ||
| Vote::Aye, | ||
| )); | ||
| } | ||
|
|
||
| // run out of voting period | ||
| <System<T>>::set_block_number( | ||
| <System<T>>::block_number() | ||
| + <T as Config>::VotingPeriod::get() * 2_u32.into() | ||
| + <T as Config>::ProposalSubmissionPeriod::get() | ||
| + 1_u32.into() | ||
| ); | ||
| }: _( | ||
| SystemOrigin::Signed(caller.clone()), | ||
| proposal.hash() | ||
| ) verify { | ||
| assert_noop!( | ||
| <Pallet<T>>::close(SystemOrigin::Signed(caller.clone()).into(), proposal.hash()), | ||
| <Error<T>>::ProposalAlreadyExecuted | ||
| ); | ||
| } | ||
|
|
||
| add_constituent { | ||
| let constituent: T::AccountId = account("constituent", 0, 0); | ||
| }: _( | ||
| SystemOrigin::Root, | ||
| constituent.clone() | ||
| ) verify { | ||
| assert!(<pallet::Members<T>>::contains_key(constituent)); | ||
| } | ||
| } |
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.