diff --git a/Cargo.lock b/Cargo.lock index 17d68dd8bb0cd24c6742d58a75663d7dd93edf75..966a4e812ae62e681570eb1e93cb1bafb0e52624 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1216,6 +1216,15 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f7144d30dcf0fafbce74250a3963025d8d52177934239851c917d29f1df280c2" +[[package]] +name = "convert_case" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec182b0ca2f35d8fc196cf3404988fd8b8c739a4d270ff118a398feb0cbec1ca" +dependencies = [ + "unicode-segmentation", +] + [[package]] name = "core-foundation" version = "0.9.3" @@ -12061,7 +12070,9 @@ dependencies = [ name = "weight-analyzer" version = "0.0.0" dependencies = [ + "convert_case", "glob", + "serde", "subweight-core", ] @@ -12421,6 +12432,7 @@ dependencies = [ "tokio", "version-compare", "version_check", + "weight-analyzer", ] [[package]] diff --git a/docs/api/runtime-calls.md b/docs/api/runtime-calls.md index e15a49ff9e7cf075fa9aab540e9d9c310ebdbbe9..f10d43642c2d99358086ca6a7bf70b027babc197 100644 --- a/docs/api/runtime-calls.md +++ b/docs/api/runtime-calls.md @@ -20,6 +20,7 @@ There are **78** user calls from **23** pallets. #### unlink_identity - 0 <details><summary><code>unlink_identity()</code></summary> +Taking 0.00314045 % of a block. ```rust ``` @@ -33,6 +34,7 @@ unlink the identity associated with the account #### schedule - 0 <details><summary><code>schedule(when, maybe_periodic, priority, call)</code></summary> +Taking 0.0045085128 % of a block. ```rust when: T::BlockNumber @@ -48,6 +50,7 @@ Anonymously schedule a task. #### cancel - 1 <details><summary><code>cancel(when, index)</code></summary> +Taking 0.00771074795 % of a block. ```rust when: T::BlockNumber @@ -61,6 +64,7 @@ Cancel an anonymously scheduled task. #### schedule_named - 2 <details><summary><code>schedule_named(id, when, maybe_periodic, priority, call)</code></summary> +Taking 0.00775320855 % of a block. ```rust id: TaskName @@ -77,6 +81,7 @@ Schedule a named task. #### cancel_named - 3 <details><summary><code>cancel_named(id)</code></summary> +Taking 0.008208497 % of a block. ```rust id: TaskName @@ -89,6 +94,7 @@ Cancel a named scheduled task. #### schedule_after - 4 <details><summary><code>schedule_after(after, maybe_periodic, priority, call)</code></summary> +Taking -1 % of a block. ```rust after: T::BlockNumber @@ -104,6 +110,7 @@ Anonymously schedule a task after a delay. #### schedule_named_after - 5 <details><summary><code>schedule_named_after(id, after, maybe_periodic, priority, call)</code></summary> +Taking -1 % of a block. ```rust id: TaskName @@ -122,6 +129,7 @@ Schedule a named task after a delay. #### report_equivocation - 0 <details><summary><code>report_equivocation(equivocation_proof, key_owner_proof)</code></summary> +Taking -1 % of a block. ```rust equivocation_proof: Box<EquivocationProof<T::Header>> @@ -140,6 +148,7 @@ be reported. #### transfer_allow_death - 0 <details><summary><code>transfer_allow_death(dest, value)</code></summary> +Taking 0.008295249999999999 % of a block. ```rust dest: AccountIdLookupOf<T> @@ -159,6 +168,7 @@ The dispatch origin for this call must be `Signed` by the transactor. #### set_balance_deprecated - 1 <details><summary><code>set_balance_deprecated(who, new_free, old_reserved)</code></summary> +Taking -1 % of a block. ```rust who: AccountIdLookupOf<T> @@ -178,6 +188,7 @@ WARNING: This call is DEPRECATED! Use `force_set_balance` instead. #### transfer_keep_alive - 3 <details><summary><code>transfer_keep_alive(dest, value)</code></summary> +Taking 0.0074474499999999996 % of a block. ```rust dest: AccountIdLookupOf<T> @@ -196,6 +207,7 @@ kill the origin account. #### transfer_all - 4 <details><summary><code>transfer_all(dest, keep_alive)</code></summary> +Taking 0.00788335 % of a block. ```rust dest: AccountIdLookupOf<T> @@ -223,6 +235,7 @@ The dispatch origin of this call must be Signed. #### transfer - 7 <details><summary><code>transfer(dest, value)</code></summary> +Taking -1 % of a block. ```rust dest: AccountIdLookupOf<T> @@ -238,6 +251,7 @@ WARNING: DEPRECATED! Will be released in approximately 3 months. #### force_set_balance - 8 <details><summary><code>force_set_balance(who, new_free)</code></summary> +Taking -1 % of a block. ```rust who: AccountIdLookupOf<T> @@ -255,6 +269,7 @@ The dispatch origin for this call is `root`. #### create_oneshot_account - 0 <details><summary><code>create_oneshot_account(dest, value)</code></summary> +Taking 0.00407265 % of a block. ```rust dest: <T::Lookup as StaticLookup>::Source @@ -273,6 +288,7 @@ Origin account is kept alive. #### consume_oneshot_account - 1 <details><summary><code>consume_oneshot_account(block_height, dest)</code></summary> +Taking 0.0076215499999999995 % of a block. ```rust block_height: T::BlockNumber @@ -290,6 +306,7 @@ Consume a oneshot account and transfer its balance to an account #### consume_oneshot_account_with_remaining - 2 <details><summary><code>consume_oneshot_account_with_remaining(block_height, dest, remaining_to, balance)</code></summary> +Taking 0.01110345 % of a block. ```rust block_height: T::BlockNumber @@ -316,6 +333,7 @@ and the remaining amount to another account. #### go_offline - 0 <details><summary><code>go_offline()</code></summary> +Taking 0.0089219 % of a block. ```rust ``` @@ -327,6 +345,7 @@ ask to leave the set of validators two sessions after #### go_online - 1 <details><summary><code>go_online()</code></summary> +Taking 0.0103085 % of a block. ```rust ``` @@ -338,6 +357,7 @@ ask to join the set of validators two sessions after #### set_session_keys - 2 <details><summary><code>set_session_keys(keys)</code></summary> +Taking 0.009799450000000001 % of a block. ```rust keys: T::Keys @@ -350,6 +370,7 @@ declare new session keys to replace current ones #### remove_member_from_blacklist - 4 <details><summary><code>remove_member_from_blacklist(member_id)</code></summary> +Taking 0.00349335 % of a block. ```rust member_id: T::MemberId @@ -364,6 +385,7 @@ remove an identity from the blacklist #### report_equivocation - 0 <details><summary><code>report_equivocation(equivocation_proof, key_owner_proof)</code></summary> +Taking -1 % of a block. ```rust equivocation_proof: Box<EquivocationProof<T::Hash, T::BlockNumber>> @@ -382,6 +404,7 @@ will be reported. #### dispatch_as_root_unchecked_weight - 1 <details><summary><code>dispatch_as_root_unchecked_weight(call, weight)</code></summary> +Taking -1 % of a block. ```rust call: Box<<T as Config>::Call> @@ -401,6 +424,7 @@ The weight of this call is defined by the caller. #### note_preimage - 0 <details><summary><code>note_preimage(bytes)</code></summary> +Taking 0.2963431912 % of a block. ```rust bytes: Vec<u8> @@ -416,6 +440,7 @@ the preimage. Otherwise, a deposit is taken proportional to the size of the prei #### unnote_preimage - 1 <details><summary><code>unnote_preimage(hash)</code></summary> +Taking 0.0081516 % of a block. ```rust hash: T::Hash @@ -433,6 +458,7 @@ If `len` is provided, then it will be a much cheaper operation. #### request_preimage - 2 <details><summary><code>request_preimage(hash)</code></summary> +Taking 0.0045000000000000005 % of a block. ```rust hash: T::Hash @@ -448,6 +474,7 @@ a user may have paid, and take the control of the preimage out of their hands. #### unrequest_preimage - 3 <details><summary><code>unrequest_preimage(hash)</code></summary> +Taking 0.0070914 % of a block. ```rust hash: T::Hash @@ -464,6 +491,7 @@ NOTE: THIS MUST NOT BE CALLED ON `hash` MORE TIMES THAN `request_preimage`. #### execute - 1 <details><summary><code>execute(proposal, length_bound)</code></summary> +Taking 0.00114356225 % of a block. ```rust proposal: Box<<T as Config<I>>::Proposal> @@ -485,6 +513,7 @@ Origin must be a member of the collective. #### propose - 2 <details><summary><code>propose(threshold, proposal, length_bound)</code></summary> +Taking -1 % of a block. ```rust threshold: MemberCount @@ -512,6 +541,7 @@ or put up for voting. #### vote - 3 <details><summary><code>vote(proposal, index, approve)</code></summary> +Taking 0.0044604425 % of a block. ```rust proposal: T::Hash @@ -534,6 +564,7 @@ fee. #### close - 6 <details><summary><code>close(proposal_hash, index, proposal_weight_bound, length_bound)</code></summary> +Taking -1 % of a block. ```rust proposal_hash: T::Hash @@ -574,6 +605,7 @@ proposal. #### claim_uds - 0 <details><summary><code>claim_uds()</code></summary> +Taking 0.008628653549999999 % of a block. ```rust ``` @@ -585,6 +617,7 @@ Claim Universal Dividends #### transfer_ud - 1 <details><summary><code>transfer_ud(dest, value)</code></summary> +Taking 0.00899295 % of a block. ```rust dest: <T::Lookup as StaticLookup>::Source @@ -598,6 +631,7 @@ Transfer some liquid free balance to another account, in milliUD. #### transfer_ud_keep_alive - 2 <details><summary><code>transfer_ud_keep_alive(dest, value)</code></summary> +Taking 0.008015949999999999 % of a block. ```rust dest: <T::Lookup as StaticLookup>::Source @@ -613,6 +647,7 @@ Transfer some liquid free balance to another account, in milliUD. #### create_identity - 0 <details><summary><code>create_identity(owner_key)</code></summary> +Taking 0.04084285 % of a block. ```rust owner_key: T::AccountId @@ -629,6 +664,7 @@ The origin must be allowed to create an identity. #### confirm_identity - 1 <details><summary><code>confirm_identity(idty_name)</code></summary> +Taking 0.013745 % of a block. ```rust idty_name: IdtyName @@ -645,6 +681,7 @@ The identity must have been created using `create_identity` before it can be con #### change_owner_key - 3 <details><summary><code>change_owner_key(new_key, new_key_sig)</code></summary> +Taking 0.02070725 % of a block. ```rust new_key: T::AccountId @@ -664,6 +701,7 @@ The origin should be the old identity owner key. #### revoke_identity - 4 <details><summary><code>revoke_identity(idty_index, revocation_key, revocation_sig)</code></summary> +Taking 0.0217495 % of a block. ```rust idty_index: T::IdtyIndex @@ -685,6 +723,7 @@ Any signed origin can execute this call. #### fix_sufficients - 7 <details><summary><code>fix_sufficients(owner_key, inc)</code></summary> +Taking 0.0033105499999999998 % of a block. ```rust owner_key: T::AccountId @@ -698,6 +737,7 @@ change sufficient ref count for given key #### link_account - 8 <details><summary><code>link_account(account_id, payload_sig)</code></summary> +Taking 0.006794100000000001 % of a block. ```rust account_id: T::AccountId @@ -713,6 +753,7 @@ Link an account to an identity #### claim_membership - 1 <details><summary><code>claim_membership()</code></summary> +Taking 0.01685205 % of a block. ```rust ``` @@ -721,12 +762,13 @@ Link an account to an identity claim membership it must fullfill the requirements (certs, distance) -for main wot claim_membership is called automatically when validating identity +TODO #159 for main wot claim_membership is called automatically when distance is evaluated positively for smith wot, it means joining the authority members #### renew_membership - 2 <details><summary><code>renew_membership()</code></summary> +Taking 0.0120386 % of a block. ```rust ``` @@ -738,6 +780,7 @@ extend the validity period of an active membership #### revoke_membership - 3 <details><summary><code>revoke_membership()</code></summary> +Taking 0.01760525 % of a block. ```rust ``` @@ -752,6 +795,7 @@ revoke an active membership #### add_cert - 0 <details><summary><code>add_cert(issuer, receiver)</code></summary> +Taking 0.0146154 % of a block. ```rust issuer: T::IdtyIndex @@ -771,6 +815,7 @@ The origin must be allow to certify. #### request_distance_evaluation - 0 <details><summary><code>request_distance_evaluation()</code></summary> +Taking 0.01423585 % of a block. ```rust ``` @@ -782,6 +827,7 @@ Request an identity to be evaluated #### update_evaluation - 1 <details><summary><code>update_evaluation(computation_result)</code></summary> +Taking 0.0146744083 % of a block. ```rust computation_result: ComputationResult @@ -794,6 +840,7 @@ computation_result: ComputationResult #### force_update_evaluation - 2 <details><summary><code>force_update_evaluation(evaluator, computation_result)</code></summary> +Taking 0.00751112 % of a block. ```rust evaluator: <T as frame_system::Config>::AccountId @@ -807,6 +854,7 @@ Push an evaluation result to the pool #### force_set_distance_status - 3 <details><summary><code>force_set_distance_status(identity, status)</code></summary> +Taking 0.006575900000000001 % of a block. ```rust identity: <T as pallet_identity::Config>::IdtyIndex @@ -828,6 +876,7 @@ Removes the status if `status` is `None`. #### claim_membership - 1 <details><summary><code>claim_membership()</code></summary> +Taking 0.01139385 % of a block. ```rust ``` @@ -836,12 +885,13 @@ Removes the status if `status` is `None`. claim membership it must fullfill the requirements (certs, distance) -for main wot claim_membership is called automatically when validating identity +TODO #159 for main wot claim_membership is called automatically when distance is evaluated positively for smith wot, it means joining the authority members #### renew_membership - 2 <details><summary><code>renew_membership()</code></summary> +Taking 0.011403100000000001 % of a block. ```rust ``` @@ -853,6 +903,7 @@ extend the validity period of an active membership #### revoke_membership - 3 <details><summary><code>revoke_membership()</code></summary> +Taking 0.0404213 % of a block. ```rust ``` @@ -867,6 +918,7 @@ revoke an active membership #### add_cert - 0 <details><summary><code>add_cert(issuer, receiver)</code></summary> +Taking 0.0148997 % of a block. ```rust issuer: T::IdtyIndex @@ -886,6 +938,7 @@ The origin must be allow to certify. #### create_swap - 0 <details><summary><code>create_swap(target, hashed_proof, action, duration)</code></summary> +Taking -1 % of a block. ```rust target: T::AccountId @@ -912,6 +965,7 @@ The dispatch origin for this call must be _Signed_. #### claim_swap - 1 <details><summary><code>claim_swap(proof, action)</code></summary> +Taking -1 % of a block. ```rust proof: Vec<u8> @@ -931,6 +985,7 @@ The dispatch origin for this call must be _Signed_. #### cancel_swap - 2 <details><summary><code>cancel_swap(target, hashed_proof)</code></summary> +Taking -1 % of a block. ```rust target: T::AccountId @@ -951,6 +1006,7 @@ The dispatch origin for this call must be _Signed_. #### as_multi_threshold_1 - 0 <details><summary><code>as_multi_threshold_1(other_signatories, call)</code></summary> +Taking 0.0004697393 % of a block. ```rust other_signatories: Vec<T::AccountId> @@ -975,6 +1031,7 @@ O(Z + C) where Z is the length of the call and C its execution weight. #### as_multi - 1 <details><summary><code>as_multi(threshold, other_signatories, maybe_timepoint, call, max_weight)</code></summary> +Taking -1 % of a block. ```rust threshold: u16 @@ -1029,6 +1086,7 @@ may be found in the deposited `MultisigExecuted` event. #### approve_as_multi - 2 <details><summary><code>approve_as_multi(threshold, other_signatories, maybe_timepoint, call_hash, max_weight)</code></summary> +Taking -1 % of a block. ```rust threshold: u16 @@ -1074,6 +1132,7 @@ NOTE: If this is the final approval, you will want to use `as_multi` instead. #### cancel_as_multi - 3 <details><summary><code>cancel_as_multi(threshold, other_signatories, timepoint, call_hash)</code></summary> +Taking 0.0044154068 % of a block. ```rust threshold: u16 @@ -1111,6 +1170,7 @@ transaction for this dispatch. #### request - 0 <details><summary><code>request(randomness_type, salt)</code></summary> +Taking 0.014593 % of a block. ```rust randomness_type: RandomnessType @@ -1126,6 +1186,7 @@ Request a randomness #### proxy - 0 <details><summary><code>proxy(real, force_proxy_type, call)</code></summary> +Taking 0.00112542355 % of a block. ```rust real: AccountIdLookupOf<T> @@ -1148,6 +1209,7 @@ Parameters: #### add_proxy - 1 <details><summary><code>add_proxy(delegate, proxy_type, delay)</code></summary> +Taking 0.00408791445 % of a block. ```rust delegate: AccountIdLookupOf<T> @@ -1170,6 +1232,7 @@ zero. #### remove_proxy - 2 <details><summary><code>remove_proxy(delegate, proxy_type, delay)</code></summary> +Taking 0.00409451075 % of a block. ```rust delegate: AccountIdLookupOf<T> @@ -1190,6 +1253,7 @@ Parameters: #### remove_proxies - 3 <details><summary><code>remove_proxies()</code></summary> +Taking 0.00398709485 % of a block. ```rust ``` @@ -1206,6 +1270,7 @@ the unreserved fees will be inaccessible. **All access to this account will be l #### create_pure - 4 <details><summary><code>create_pure(proxy_type, delay, index)</code></summary> +Taking 0.0041442946999999996 % of a block. ```rust proxy_type: T::ProxyType @@ -1237,6 +1302,7 @@ Fails if there are insufficient funds to pay for deposit. #### kill_pure - 5 <details><summary><code>kill_pure(spawner, proxy_type, index, height, ext_index)</code></summary> +Taking 0.00403936515 % of a block. ```rust spawner: AccountIdLookupOf<T> @@ -1268,6 +1334,7 @@ account whose `pure` call has corresponding parameters. #### announce - 6 <details><summary><code>announce(real, call_hash)</code></summary> +Taking 0.0079946957 % of a block. ```rust real: AccountIdLookupOf<T> @@ -1295,6 +1362,7 @@ Parameters: #### remove_announcement - 7 <details><summary><code>remove_announcement(real, call_hash)</code></summary> +Taking 0.00720332345 % of a block. ```rust real: AccountIdLookupOf<T> @@ -1317,6 +1385,7 @@ Parameters: #### reject_announcement - 8 <details><summary><code>reject_announcement(delegate, call_hash)</code></summary> +Taking 0.00721393205 % of a block. ```rust delegate: AccountIdLookupOf<T> @@ -1339,6 +1408,7 @@ Parameters: #### proxy_announced - 9 <details><summary><code>proxy_announced(delegate, real, force_proxy_type, call)</code></summary> +Taking 0.0081714508 % of a block. ```rust delegate: AccountIdLookupOf<T> @@ -1366,6 +1436,7 @@ Parameters: #### batch - 0 <details><summary><code>batch(calls)</code></summary> +Taking 0.1978951879 % of a block. ```rust calls: Vec<<T as Config>::RuntimeCall> @@ -1395,6 +1466,7 @@ event is deposited. #### as_derivative - 1 <details><summary><code>as_derivative(index, call)</code></summary> +Taking 0.0001795 % of a block. ```rust index: u16 @@ -1420,6 +1492,7 @@ The dispatch origin for this call must be _Signed_. #### batch_all - 2 <details><summary><code>batch_all(calls)</code></summary> +Taking 0.2050479986 % of a block. ```rust calls: Vec<<T as Config>::RuntimeCall> @@ -1444,6 +1517,7 @@ includes bypassing `frame_system::Config::BaseCallFilter`). #### force_batch - 4 <details><summary><code>force_batch(calls)</code></summary> +Taking 0.19725465265000003 % of a block. ```rust calls: Vec<<T as Config>::RuntimeCall> @@ -1468,6 +1542,7 @@ includes bypassing `frame_system::Config::BaseCallFilter`). #### with_weight - 5 <details><summary><code>with_weight(call, weight)</code></summary> +Taking -1 % of a block. ```rust call: Box<<T as Config>::RuntimeCall> @@ -1488,6 +1563,7 @@ The dispatch origin for this call must be _Root_. #### propose_spend - 0 <details><summary><code>propose_spend(value, beneficiary)</code></summary> +Taking 0.0066688 % of a block. ```rust value: BalanceOf<T, I> @@ -1506,6 +1582,7 @@ proposal is awarded. #### spend - 3 <details><summary><code>spend(amount, beneficiary)</code></summary> +Taking 0.00000915 % of a block. ```rust amount: BalanceOf<T, I> @@ -1526,6 +1603,7 @@ beneficiary. #### remove_approval - 4 <details><summary><code>remove_approval(proposal_id)</code></summary> +Taking 0.0032549499999999995 % of a block. ```rust proposal_id: ProposalIndex @@ -1558,6 +1636,7 @@ There are **19** root calls from **10** pallets. #### set_heap_pages - 1 <details><summary><code>set_heap_pages(pages)</code></summary> +Taking 0.00571225 % of a block. ```rust pages: u64 @@ -1570,6 +1649,7 @@ Set the number of pages in the WebAssembly environment's heap. #### set_code - 2 <details><summary><code>set_code(code)</code></summary> +Taking -1 % of a block. ```rust code: Vec<u8> @@ -1585,6 +1665,7 @@ Set the new runtime code. #### set_code_without_checks - 3 <details><summary><code>set_code_without_checks(code)</code></summary> +Taking -1 % of a block. ```rust code: Vec<u8> @@ -1600,6 +1681,7 @@ Set the new runtime code without doing any checks of the given `code`. #### set_storage - 4 <details><summary><code>set_storage(items)</code></summary> +Taking 2.61958365 % of a block. ```rust items: Vec<KeyValue> @@ -1612,6 +1694,7 @@ Set some items of storage. #### kill_storage - 5 <details><summary><code>kill_storage(keys)</code></summary> +Taking 2.6116451499999997 % of a block. ```rust keys: Vec<Key> @@ -1624,6 +1707,7 @@ Kill some items from storage. #### kill_prefix - 6 <details><summary><code>kill_prefix(prefix, subkeys)</code></summary> +Taking 2.9997642 % of a block. ```rust prefix: Key @@ -1642,6 +1726,7 @@ the prefix we are removing to accurately calculate the weight of this function. #### plan_config_change - 2 <details><summary><code>plan_config_change(config)</code></summary> +Taking -1 % of a block. ```rust config: NextConfigDescriptor @@ -1659,6 +1744,7 @@ not been enacted yet. #### force_transfer - 2 <details><summary><code>force_transfer(source, dest, value)</code></summary> +Taking 0.0114141 % of a block. ```rust source: AccountIdLookupOf<T> @@ -1674,6 +1760,7 @@ may be specified. #### force_unreserve - 5 <details><summary><code>force_unreserve(who, amount)</code></summary> +Taking 0.0037478999999999998 % of a block. ```rust who: AccountIdLookupOf<T> @@ -1691,6 +1778,7 @@ Can only be called by ROOT. #### remove_member - 3 <details><summary><code>remove_member(member_id)</code></summary> +Taking 0.04294555 % of a block. ```rust member_id: T::MemberId @@ -1705,6 +1793,7 @@ remove an identity from the set of authorities #### note_stalled - 2 <details><summary><code>note_stalled(delay, best_finalized_block_number)</code></summary> +Taking -1 % of a block. ```rust delay: T::BlockNumber @@ -1731,6 +1820,7 @@ Only callable by root. #### set_members - 0 <details><summary><code>set_members(new_members, prime, old_count)</code></summary> +Taking 0.078102428 % of a block. ```rust new_members: Vec<T::AccountId> @@ -1768,6 +1858,7 @@ with other logic managing the member set. #### disapprove_proposal - 5 <details><summary><code>disapprove_proposal(proposal_hash)</code></summary> +Taking 0.009028286299999999 % of a block. ```rust proposal_hash: T::Hash @@ -1791,6 +1882,7 @@ O(P) where P is the number of max proposals #### prune_item_identities_names - 6 <details><summary><code>prune_item_identities_names(names)</code></summary> +Taking 2.6528971500000003 % of a block. ```rust names: Vec<IdtyName> @@ -1805,6 +1897,7 @@ remove identity names from storage #### del_cert - 1 <details><summary><code>del_cert(issuer, receiver)</code></summary> +Taking 0.010917300000000001 % of a block. ```rust issuer: T::IdtyIndex @@ -1818,6 +1911,7 @@ remove a certification (only root) #### remove_all_certs_received_by - 2 <details><summary><code>remove_all_certs_received_by(idty_index)</code></summary> +Taking 3.50323325 % of a block. ```rust idty_index: T::IdtyIndex @@ -1832,6 +1926,7 @@ remove all certifications received by an identity (only root) #### del_cert - 1 <details><summary><code>del_cert(issuer, receiver)</code></summary> +Taking 0.010896999999999999 % of a block. ```rust issuer: T::IdtyIndex @@ -1845,6 +1940,7 @@ remove a certification (only root) #### remove_all_certs_received_by - 2 <details><summary><code>remove_all_certs_received_by(idty_index)</code></summary> +Taking 3.4988980000000005 % of a block. ```rust idty_index: T::IdtyIndex @@ -1859,6 +1955,7 @@ remove all certifications received by an identity (only root) #### dispatch_as - 3 <details><summary><code>dispatch_as(as_origin, call)</code></summary> +Taking 0.00036205 % of a block. ```rust as_origin: Box<T::PalletsOrigin> @@ -1888,6 +1985,7 @@ There are **4** disabled calls from **2** pallets. #### remark - 0 <details><summary><code>remark(remark)</code></summary> +Taking 0.05257243599999999 % of a block. ```rust remark: Vec<u8> @@ -1903,6 +2001,7 @@ Make some on-chain remark. #### remark_with_event - 7 <details><summary><code>remark_with_event(remark)</code></summary> +Taking 0.21203131600000003 % of a block. ```rust remark: Vec<u8> @@ -1917,6 +2016,7 @@ Make some on-chain remark and emit event. #### set_keys - 0 <details><summary><code>set_keys(keys, proof)</code></summary> +Taking 0.01598685 % of a block. ```rust keys: T::Keys @@ -1938,6 +2038,7 @@ The dispatch origin of this function must be signed. #### purge_keys - 1 <details><summary><code>purge_keys()</code></summary> +Taking 0.01406905 % of a block. ```rust ``` diff --git a/docs/api/runtime-errors.md b/docs/api/runtime-errors.md index 5feb1cf038c4e5e5ae19be103634e356ec1b6515..80eb0c2d43d9561b4746763383c3b36b9b7335af 100644 --- a/docs/api/runtime-errors.md +++ b/docs/api/runtime-errors.md @@ -1,6 +1,6 @@ # Runtime errors -There are **186** errors from **37** pallets. +There are **187** errors from **37** pallets. <ul> <li>System - 0 @@ -818,7 +818,7 @@ Invalid revocation key. <details> <summary> <code>IssuerNotMember</code> - 10</summary> -Issuer is not member and can not perform this action +Issuer is not member and can not perform this action. </details> </li> <li> @@ -853,21 +853,28 @@ Reverting to an old key is prohibited. <details> <summary> <code>AlreadyRevoked</code> - 15</summary> -Already revoked +Already revoked. </details> </li> <li> <details> <summary> <code>CanNotRevokeUnconfirmed</code> - 16</summary> -Can not revoke identity that never was member +Can not revoke identity that never was member. </details> </li> <li> <details> <summary> <code>CanNotRevokeUnvalidated</code> - 17</summary> -Can not revoke identity that never was member +Can not revoke identity that never was member. +</details> +</li> +<li> +<details> +<summary> +<code>AccountNotExist</code> - 18</summary> +Cannot link to an inexisting account. </details> </li> </ul> diff --git a/docs/api/runtime-events.md b/docs/api/runtime-events.md index cd058e2b44ecf4afb7ca98486c4ad0aefeb5649d..05a1536de903a9d6c983054688adb20a6a662463 100644 --- a/docs/api/runtime-events.md +++ b/docs/api/runtime-events.md @@ -1,6 +1,6 @@ # Runtime events -There are **126** events from **37** pallets. +There are **127** events from **37** pallets. <ul> <li>System - 0 @@ -716,6 +716,18 @@ A member has been removed from the blacklist. member: T::MemberId ``` +</details> +</li> +<li> +<details> +<summary> +<code>MemberAddedToBlacklist(member)</code> - 6</summary> +A member has been blacklisted. + +```rust +member: T::MemberId +``` + </details> </li> </ul> diff --git a/xtask/Cargo.toml b/xtask/Cargo.toml index 4ed72ab585f7698b4e017014744650640e9ae244..05166cc4ee3994bc4bb46b786dee5179de184850 100644 --- a/xtask/Cargo.toml +++ b/xtask/Cargo.toml @@ -30,3 +30,4 @@ tokio = { version = "1.24.2", features = ["macros"] } version_check = "0.9.2" version-compare = "0.0.11" tera = { version = "1", default-features = false } +weight-analyzer = {path = "../resources/weight_analyzer"} diff --git a/xtask/res/templates/runtime-calls-category.md b/xtask/res/templates/runtime-calls-category.md index efe447ef4a9afeecea54745b9053e767670ab888..581b11409a459044ea8a83fd0a814133d4e45215 100644 --- a/xtask/res/templates/runtime-calls-category.md +++ b/xtask/res/templates/runtime-calls-category.md @@ -8,9 +8,10 @@ There are **{{ calls_counter }}** {{ category_name }} calls from **{{ pallets | <details><summary><code>{{ call.name }}( {%- for param in call.params -%} - {{ param.name }}{% if loop.last != true %}, {% endif %} + {{ param.name }}{% if loop.last != true %}, {% endif %} {%- endfor -%} )</code></summary> +Taking {{ call.weight}} % of a block. ```rust {% for param in call.params -%} diff --git a/xtask/src/gen_doc.rs b/xtask/src/gen_doc.rs index 9f077659c73de0d17606231665d2a068f92615d6..5cc027593bd2b418db705930f7e36703fe0efb64 100644 --- a/xtask/src/gen_doc.rs +++ b/xtask/src/gen_doc.rs @@ -16,13 +16,28 @@ use anyhow::{bail, Context, Result}; use codec::Decode; +use core::hash::Hash; use scale_info::form::PortableForm; use serde::Serialize; +use std::collections::HashMap; +use std::path::Path; use std::{ fs::File, io::{Read, Write}, }; use tera::Tera; +use weightanalyzer::analyze_weight; +use weightanalyzer::MaxBlockWeight; +use weightanalyzer::WeightInfo; + +fn rename_key<K, V>(h: &mut HashMap<K, V>, old_key: &K, new_key: K) +where + K: Eq + Hash, +{ + if let Some(v) = h.remove(old_key) { + h.insert(new_key, v); + } +} // consts @@ -30,6 +45,7 @@ const CALLS_DOC_FILEPATH: &str = "docs/api/runtime-calls.md"; const EVENTS_DOC_FILEPATH: &str = "docs/api/runtime-events.md"; const ERRORS_DOC_FILEPATH: &str = "docs/api/runtime-errors.md"; const TEMPLATES_GLOB: &str = "xtask/res/templates/*.md"; +const WEIGHT_FILEPATH: &str = "runtime/common/src/weights/"; // define structs and implementations @@ -49,6 +65,7 @@ struct Call { index: u8, name: String, params: Vec<CallParam>, + weight: f64, } #[derive(Clone, Serialize)] struct CallParam { @@ -132,6 +149,7 @@ impl From<&scale_info::Variant<PortableForm>> for Call { index: variant.index, name: variant.name.to_owned(), params: variant.fields.iter().map(Into::into).collect(), + weight: Default::default(), } } } @@ -237,12 +255,56 @@ pub(super) fn gen_doc() -> Result<()> { println!("Metadata successfully loaded!"); - let runtime = if let frame_metadata::RuntimeMetadata::V14(metadata_v14) = metadata.1 { + let mut runtime = if let frame_metadata::RuntimeMetadata::V14(metadata_v14) = metadata.1 { get_from_metadata_v14(metadata_v14)? } else { bail!("unsuported metadata version") }; + let mut weights = get_weights(); // Panic if not possible + println!("{:?}", weights.get("Balances")); // Debug + + // AdHoc names convertion + // TODO automatic??? + rename_key(&mut weights, &"FrameSystem".into(), "System".into()); + rename_key(&mut weights, &"DuniterAccount".into(), "Account".into()); + rename_key( + &mut weights, + &"Collective".into(), + "TechnicalCommittee".into(), + ); + rename_key( + &mut weights, + &"MembershipMembership".into(), + "Membership".into(), + ); + rename_key( + &mut weights, + &"MembershipSmithMembership".into(), + "SmithMembership".into(), + ); + rename_key(&mut weights, &"CertificationCert".into(), "Cert".into()); + rename_key( + &mut weights, + &"CertificationSmithCert".into(), + "SmithCert".into(), + ); + // Pallet with manual benchmark + weights.insert("Babe".to_string(), Default::default()); + weights.insert("Grandpa".to_string(), Default::default()); + weights.insert("Sudo".to_string(), Default::default()); + weights.insert("AtomicSwap".to_string(), Default::default()); + // Insert weights + runtime.iter_mut().for_each(|pallet| { + pallet.calls.iter_mut().for_each(|call| { + call.weight = weights + .get(&pallet.name) + .expect(&("No weight for ".to_owned() + &pallet.name)) + .get(&call.name) + .map_or(-1f64, |weight| weight.relative_weight) + }) + }); + let (call_doc, event_doc, error_doc) = print_runtime(runtime); let mut file = File::create(CALLS_DOC_FILEPATH) @@ -326,6 +388,10 @@ fn get_from_metadata_v14( Ok(pallets) } +fn get_weights() -> HashMap<String, HashMap<String, WeightInfo>> { + analyze_weight(Path::new(WEIGHT_FILEPATH), &MaxBlockWeight::default()) +} + /// use template to render markdown file with runtime calls documentation fn print_runtime(pallets: RuntimePallets) -> (String, String, String) { // init variables