From d991d60188f39caf4d36f8bbf742977db115f7f4 Mon Sep 17 00:00:00 2001 From: bgallois <benjamin@gallois.cc> Date: Wed, 29 Jan 2025 18:09:20 +0100 Subject: [PATCH 1/7] add storages --- docs/api/runtime-storages.md | 2275 +++++++++++++++++++++++ xtask/res/templates/runtime-storages.md | 28 + xtask/src/gen_doc.rs | 94 +- 3 files changed, 2394 insertions(+), 3 deletions(-) create mode 100644 docs/api/runtime-storages.md create mode 100644 xtask/res/templates/runtime-storages.md diff --git a/docs/api/runtime-storages.md b/docs/api/runtime-storages.md new file mode 100644 index 000000000..a6022c323 --- /dev/null +++ b/docs/api/runtime-storages.md @@ -0,0 +1,2275 @@ +# Runtime Storage + +There are **136** storages from **35** pallets. + +<ul> + +<li>System - 0 +<ul> + +<li> +<details> +<summary> +<code>Account</code> +</summary> + The full account information for a particular account ID. + +```rust +key: sp_core::crypto::AccountId32 +value: frame_system::AccountInfo +``` + +</details> +</li> + +<li> +<details> +<summary> +<code>ExtrinsicCount</code> +</summary> + Total extrinsics count for the current block. + +```rust +value: U32 +``` + +</details> +</li> + +<li> +<details> +<summary> +<code>InherentsApplied</code> +</summary> + Whether all inherents have been applied. + +```rust +value: Bool +``` + +</details> +</li> + +<li> +<details> +<summary> +<code>BlockWeight</code> +</summary> + The current weight for the block. + +```rust +value: frame_support::dispatch::PerDispatchClass +``` + +</details> +</li> + +<li> +<details> +<summary> +<code>AllExtrinsicsLen</code> +</summary> + Total length (in bytes) for all extrinsics put together, for the current block. + +```rust +value: U32 +``` + +</details> +</li> + +<li> +<details> +<summary> +<code>BlockHash</code> +</summary> + Map of block numbers to block hashes. + +```rust +key: U32 +value: primitive_types::H256 +``` + +</details> +</li> + +<li> +<details> +<summary> +<code>ExtrinsicData</code> +</summary> + Extrinsics data for the current block (maps an extrinsic's index to its data). + +```rust +key: U32 + +``` + +</details> +</li> + +<li> +<details> +<summary> +<code>Number</code> +</summary> + The current block number being processed. Set by `execute_block`. + +```rust +value: U32 +``` + +</details> +</li> + +<li> +<details> +<summary> +<code>ParentHash</code> +</summary> + Hash of the previous block. + +```rust +value: primitive_types::H256 +``` + +</details> +</li> + +<li> +<details> +<summary> +<code>Digest</code> +</summary> + Digest of the current block, also part of the block header. + +```rust +value: sp_runtime::generic::digest::Digest +``` + +</details> +</li> + +<li> +<details> +<summary> +<code>Events</code> +</summary> + Events deposited for the current block. + + NOTE: The item is unbound and should therefore never be read on chain. + It could otherwise inflate the PoV size of a block. + + Events have a large in-memory size. Box the events to not go out-of-memory + just in case someone still reads them from within the runtime. + + + +</details> +</li> + +<li> +<details> +<summary> +<code>EventCount</code> +</summary> + The number of events in the `Events<T>` list. + +```rust +value: U32 +``` + +</details> +</li> + +<li> +<details> +<summary> +<code>EventTopics</code> +</summary> + Mapping between a topic (represented by T::Hash) and a vector of indexes + of events in the `<Events<T>>` list. + + All topic vectors have deterministic storage locations depending on the topic. This + allows light-clients to leverage the changes trie storage tracking mechanism and + in case of changes fetch the list of events of interest. + + The value has the type `(BlockNumberFor<T>, EventIndex)` because if we used only just + the `EventIndex` then in case if the topic has the same contents on the next block + no notification will be triggered thus the event might be lost. + +```rust +key: primitive_types::H256 + +``` + +</details> +</li> + +<li> +<details> +<summary> +<code>LastRuntimeUpgrade</code> +</summary> + Stores the `spec_version` and `spec_name` of when the last runtime upgrade happened. + +```rust +value: frame_system::LastRuntimeUpgradeInfo +``` + +</details> +</li> + +<li> +<details> +<summary> +<code>UpgradedToU32RefCount</code> +</summary> + True if we have upgraded so that `type RefCount` is `u32`. False (default) if not. + +```rust +value: Bool +``` + +</details> +</li> + +<li> +<details> +<summary> +<code>UpgradedToTripleRefCount</code> +</summary> + True if we have upgraded so that AccountInfo contains three types of `RefCount`. False + (default) if not. + +```rust +value: Bool +``` + +</details> +</li> + +<li> +<details> +<summary> +<code>ExecutionPhase</code> +</summary> + The execution phase of the block. + +```rust +value: frame_system::Phase +``` + +</details> +</li> + +<li> +<details> +<summary> +<code>AuthorizedUpgrade</code> +</summary> + `Some` if a code upgrade has been authorized. + +```rust +value: frame_system::CodeUpgradeAuthorization +``` + +</details> +</li> + +</ul> +</li> + +<li>Account - 1 +<ul> + +</ul> +</li> + +<li>Scheduler - 2 +<ul> + +<li> +<details> +<summary> +<code>IncompleteSince</code> +</summary> + + +```rust +value: U32 +``` + +</details> +</li> + +<li> +<details> +<summary> +<code>Agenda</code> +</summary> + Items to be executed, indexed by the block number that they should be executed on. + +```rust +key: U32 +value: bounded_collections::bounded_vec::BoundedVec +``` + +</details> +</li> + +<li> +<details> +<summary> +<code>Retries</code> +</summary> + Retry configurations for items to be executed, indexed by task address. + +```rust +value: pallet_scheduler::RetryConfig +``` + +</details> +</li> + +<li> +<details> +<summary> +<code>Lookup</code> +</summary> + Lookup from a name to the block number and index of the task. + + For v3 -> v4 the previously unbounded identities are Blake2-256 hashed to form the v4 + identities. + + + +</details> +</li> + +</ul> +</li> + +<li>Babe - 3 +<ul> + +<li> +<details> +<summary> +<code>EpochIndex</code> +</summary> + Current epoch index. + +```rust +value: U64 +``` + +</details> +</li> + +<li> +<details> +<summary> +<code>Authorities</code> +</summary> + Current epoch authorities. + +```rust +value: bounded_collections::weak_bounded_vec::WeakBoundedVec +``` + +</details> +</li> + +<li> +<details> +<summary> +<code>GenesisSlot</code> +</summary> + The slot at which the first epoch actually started. This is 0 + until the first block of the chain. + +```rust +value: sp_consensus_slots::Slot +``` + +</details> +</li> + +<li> +<details> +<summary> +<code>CurrentSlot</code> +</summary> + Current slot number. + +```rust +value: sp_consensus_slots::Slot +``` + +</details> +</li> + +<li> +<details> +<summary> +<code>Randomness</code> +</summary> + The epoch randomness for the *current* epoch. + + # Security + + This MUST NOT be used for gambling, as it can be influenced by a + malicious validator in the short term. It MAY be used in many + cryptographic protocols, however, so long as one remembers that this + (like everything else on-chain) it is public. For example, it can be + used where a number is needed that cannot have been chosen by an + adversary, for purposes such as public-coin zero-knowledge proofs. + + + +</details> +</li> + +<li> +<details> +<summary> +<code>PendingEpochConfigChange</code> +</summary> + Pending epoch configuration change that will be applied when the next epoch is enacted. + +```rust +value: sp_consensus_babe::digests::NextConfigDescriptor +``` + +</details> +</li> + +<li> +<details> +<summary> +<code>NextRandomness</code> +</summary> + Next epoch randomness. + + + +</details> +</li> + +<li> +<details> +<summary> +<code>NextAuthorities</code> +</summary> + Next epoch authorities. + +```rust +value: bounded_collections::weak_bounded_vec::WeakBoundedVec +``` + +</details> +</li> + +<li> +<details> +<summary> +<code>SegmentIndex</code> +</summary> + Randomness under construction. + + We make a trade-off between storage accesses and list length. + We store the under-construction randomness in segments of up to + `UNDER_CONSTRUCTION_SEGMENT_LENGTH`. + + Once a segment reaches this length, we begin the next one. + We reset all segments and return to `0` at the beginning of every + epoch. + +```rust +value: U32 +``` + +</details> +</li> + +<li> +<details> +<summary> +<code>UnderConstruction</code> +</summary> + TWOX-NOTE: `SegmentIndex` is an increasing integer, so this is okay. + +```rust +key: U32 +value: bounded_collections::bounded_vec::BoundedVec +``` + +</details> +</li> + +<li> +<details> +<summary> +<code>Initialized</code> +</summary> + Temporary value (cleared at block finalization) which is `Some` + if per-block initialization has already been called for current block. + +```rust +value: Option +``` + +</details> +</li> + +<li> +<details> +<summary> +<code>AuthorVrfRandomness</code> +</summary> + This field should always be populated during block processing unless + secondary plain slots are enabled (which don't contain a VRF output). + + It is set in `on_finalize`, before it will contain the value from the last block. + +```rust +value: Option +``` + +</details> +</li> + +<li> +<details> +<summary> +<code>EpochStart</code> +</summary> + The block numbers when the last and current epoch have started, respectively `N-1` and + `N`. + NOTE: We track this is in order to annotate the block number when a given pool of + entropy was fixed (i.e. it was known to chain observers). Since epochs are defined in + slots, which may be skipped, the block numbers may not line up with the slot numbers. + + + +</details> +</li> + +<li> +<details> +<summary> +<code>Lateness</code> +</summary> + How late the current block is compared to its parent. + + This entry is populated as part of block execution and is cleaned up + on block finalization. Querying this storage entry outside of block + execution context should always yield zero. + +```rust +value: U32 +``` + +</details> +</li> + +<li> +<details> +<summary> +<code>EpochConfig</code> +</summary> + The configuration for the current epoch. Should never be `None` as it is initialized in + genesis. + +```rust +value: sp_consensus_babe::BabeEpochConfiguration +``` + +</details> +</li> + +<li> +<details> +<summary> +<code>NextEpochConfig</code> +</summary> + The configuration for the next epoch, `None` if the config will not change + (you can fallback to `EpochConfig` instead in that case). + +```rust +value: sp_consensus_babe::BabeEpochConfiguration +``` + +</details> +</li> + +<li> +<details> +<summary> +<code>SkippedEpochs</code> +</summary> + A list of the last 100 skipped epochs and the corresponding session index + when the epoch was skipped. + + This is only used for validating equivocation proofs. An equivocation proof + must contains a key-ownership proof for a given session, therefore we need a + way to tie together sessions and epoch indices, i.e. we need to validate that + a validator was the owner of a given key on a given session, and what the + active epoch index was during that session. + +```rust +value: bounded_collections::bounded_vec::BoundedVec +``` + +</details> +</li> + +</ul> +</li> + +<li>Timestamp - 4 +<ul> + +<li> +<details> +<summary> +<code>Now</code> +</summary> + The current time for the current block. + +```rust +value: U64 +``` + +</details> +</li> + +<li> +<details> +<summary> +<code>DidUpdate</code> +</summary> + Whether the timestamp has been updated in this block. + + This value is updated to `true` upon successful submission of a timestamp by a node. + It is then checked at the end of each block execution in the `on_finalize` hook. + +```rust +value: Bool +``` + +</details> +</li> + +</ul> +</li> + +<li>Parameters - 5 +<ul> + +<li> +<details> +<summary> +<code>ParametersStorage</code> +</summary> + + +```rust +value: pallet_duniter_test_parameters::types::Parameters +``` + +</details> +</li> + +</ul> +</li> + +<li>Balances - 6 +<ul> + +<li> +<details> +<summary> +<code>TotalIssuance</code> +</summary> + The total units issued in the system. + +```rust +value: U64 +``` + +</details> +</li> + +<li> +<details> +<summary> +<code>InactiveIssuance</code> +</summary> + The total units of outstanding deactivated balance in the system. + +```rust +value: U64 +``` + +</details> +</li> + +<li> +<details> +<summary> +<code>Account</code> +</summary> + The Balances pallet example of storing the balance of an account. + + # Example + + ```nocompile + impl pallet_balances::Config for Runtime { + type AccountStore = StorageMapShim<Self::Account<Runtime>, frame_system::Provider<Runtime>, AccountId, Self::AccountData<Balance>> + } + ``` + + You can also store the balance of an account in the `System` pallet. + + # Example + + ```nocompile + impl pallet_balances::Config for Runtime { + type AccountStore = System + } + ``` + + But this comes with tradeoffs, storing account balances in the system pallet stores + `frame_system` data alongside the account data contrary to storing account balances in the + `Balances` pallet, which uses a `StorageMap` to store balances data only. + NOTE: This is only used in the case that this pallet is used to store balances. + +```rust +key: sp_core::crypto::AccountId32 +value: pallet_balances::types::AccountData +``` + +</details> +</li> + +<li> +<details> +<summary> +<code>Locks</code> +</summary> + Any liquidity locks on some account balances. + NOTE: Should only be accessed when setting, changing and freeing a lock. + + Use of locks is deprecated in favour of freezes. See `https://github.com/paritytech/substrate/pull/12951/` + +```rust +key: sp_core::crypto::AccountId32 +value: bounded_collections::weak_bounded_vec::WeakBoundedVec +``` + +</details> +</li> + +<li> +<details> +<summary> +<code>Reserves</code> +</summary> + Named reserves on some account balances. + + Use of reserves is deprecated in favour of holds. See `https://github.com/paritytech/substrate/pull/12951/` + +```rust +key: sp_core::crypto::AccountId32 +value: bounded_collections::bounded_vec::BoundedVec +``` + +</details> +</li> + +<li> +<details> +<summary> +<code>Holds</code> +</summary> + Holds on account balances. + +```rust +key: sp_core::crypto::AccountId32 +value: bounded_collections::bounded_vec::BoundedVec +``` + +</details> +</li> + +<li> +<details> +<summary> +<code>Freezes</code> +</summary> + Freeze locks on account balances. + +```rust +key: sp_core::crypto::AccountId32 +value: bounded_collections::bounded_vec::BoundedVec +``` + +</details> +</li> + +</ul> +</li> + +<li>TransactionPayment - 32 +<ul> + +<li> +<details> +<summary> +<code>NextFeeMultiplier</code> +</summary> + + +```rust +value: sp_arithmetic::fixed_point::FixedU128 +``` + +</details> +</li> + +<li> +<details> +<summary> +<code>StorageVersion</code> +</summary> + + +```rust +value: pallet_transaction_payment::Releases +``` + +</details> +</li> + +</ul> +</li> + +<li>OneshotAccount - 7 +<ul> + +<li> +<details> +<summary> +<code>OneshotAccounts</code> +</summary> + The balance for each oneshot account. + +```rust +key: sp_core::crypto::AccountId32 +value: U64 +``` + +</details> +</li> + +</ul> +</li> + +<li>Quota - 66 +<ul> + +<li> +<details> +<summary> +<code>IdtyQuota</code> +</summary> + The quota for each identity. + +```rust +key: U32 +value: pallet_quota::pallet::Quota +``` + +</details> +</li> + +<li> +<details> +<summary> +<code>RefundQueue</code> +</summary> + The fees waiting to be refunded. + +```rust +value: bounded_collections::bounded_vec::BoundedVec +``` + +</details> +</li> + +</ul> +</li> + +<li>SmithMembers - 10 +<ul> + +<li> +<details> +<summary> +<code>Smiths</code> +</summary> + The Smith metadata for each identity. + +```rust +key: U32 +value: pallet_smith_members::types::SmithMeta +``` + +</details> +</li> + +<li> +<details> +<summary> +<code>ExpiresOn</code> +</summary> + The indexes of Smith to remove at a given session. + +```rust +key: U32 + +``` + +</details> +</li> + +<li> +<details> +<summary> +<code>CurrentSession</code> +</summary> + The current session index. + +```rust +value: U32 +``` + +</details> +</li> + +</ul> +</li> + +<li>AuthorityMembers - 11 +<ul> + +<li> +<details> +<summary> +<code>IncomingAuthorities</code> +</summary> + The incoming authorities. + + + +</details> +</li> + +<li> +<details> +<summary> +<code>OnlineAuthorities</code> +</summary> + The online authorities. + + + +</details> +</li> + +<li> +<details> +<summary> +<code>OutgoingAuthorities</code> +</summary> + The outgoing authorities. + + + +</details> +</li> + +<li> +<details> +<summary> +<code>Members</code> +</summary> + The member data. + +```rust +key: U32 +value: pallet_authority_members::types::MemberData +``` + +</details> +</li> + +<li> +<details> +<summary> +<code>Blacklist</code> +</summary> + The blacklisted authorities. + + + +</details> +</li> + +</ul> +</li> + +<li>Authorship - 12 +<ul> + +<li> +<details> +<summary> +<code>Author</code> +</summary> + Author of current block. + +```rust +value: sp_core::crypto::AccountId32 +``` + +</details> +</li> + +</ul> +</li> + +<li>Offences - 13 +<ul> + +<li> +<details> +<summary> +<code>Reports</code> +</summary> + The primary structure that holds all offence records keyed by report identifiers. + +```rust +key: primitive_types::H256 +value: sp_staking::offence::OffenceDetails +``` + +</details> +</li> + +<li> +<details> +<summary> +<code>ConcurrentReportsIndex</code> +</summary> + A vector of reports of the same kind that happened at the same time slot. + + + +</details> +</li> + +</ul> +</li> + +<li>Historical - 14 +<ul> + +<li> +<details> +<summary> +<code>HistoricalSessions</code> +</summary> + Mapping from historical session indices to session-data root hash and validator count. + +```rust +key: U32 + +``` + +</details> +</li> + +<li> +<details> +<summary> +<code>StoredRange</code> +</summary> + The range of historical sessions we store. [first, last) + + + +</details> +</li> + +</ul> +</li> + +<li>Session - 15 +<ul> + +<li> +<details> +<summary> +<code>Validators</code> +</summary> + The current set of validators. + + + +</details> +</li> + +<li> +<details> +<summary> +<code>CurrentIndex</code> +</summary> + Current index of the session. + +```rust +value: U32 +``` + +</details> +</li> + +<li> +<details> +<summary> +<code>QueuedChanged</code> +</summary> + True if the underlying economic identities or weighting behind the validators + has changed in the queued validator set. + +```rust +value: Bool +``` + +</details> +</li> + +<li> +<details> +<summary> +<code>QueuedKeys</code> +</summary> + The queued keys for the next session. When the next session begins, these keys + will be used to determine the validator's session keys. + + + +</details> +</li> + +<li> +<details> +<summary> +<code>DisabledValidators</code> +</summary> + Indices of disabled validators. + + The vec is always kept sorted so that we can find whether a given validator is + disabled using binary search. It gets cleared when `on_session_ending` returns + a new set of identities. + + + +</details> +</li> + +<li> +<details> +<summary> +<code>NextKeys</code> +</summary> + The next session keys for a validator. + +```rust +key: sp_core::crypto::AccountId32 +value: gdev_runtime::opaque::SessionKeys +``` + +</details> +</li> + +<li> +<details> +<summary> +<code>KeyOwner</code> +</summary> + The owner of a key. The key is the `KeyTypeId` + the encoded key. + +```rust +value: sp_core::crypto::AccountId32 +``` + +</details> +</li> + +</ul> +</li> + +<li>Grandpa - 16 +<ul> + +<li> +<details> +<summary> +<code>State</code> +</summary> + State of the current authority set. + +```rust +value: pallet_grandpa::StoredState +``` + +</details> +</li> + +<li> +<details> +<summary> +<code>PendingChange</code> +</summary> + Pending change: (signaled at, scheduled change). + +```rust +value: pallet_grandpa::StoredPendingChange +``` + +</details> +</li> + +<li> +<details> +<summary> +<code>NextForced</code> +</summary> + next block number where we can force a change. + +```rust +value: U32 +``` + +</details> +</li> + +<li> +<details> +<summary> +<code>Stalled</code> +</summary> + `true` if we are currently stalled. + + + +</details> +</li> + +<li> +<details> +<summary> +<code>CurrentSetId</code> +</summary> + The number of changes (both in terms of keys and underlying economic responsibilities) + in the "set" of Grandpa validators from genesis. + +```rust +value: U64 +``` + +</details> +</li> + +<li> +<details> +<summary> +<code>SetIdSession</code> +</summary> + A mapping from grandpa set ID to the index of the *most recent* session for which its + members were responsible. + + This is only used for validating equivocation proofs. An equivocation proof must + contains a key-ownership proof for a given session, therefore we need a way to tie + together sessions and GRANDPA set ids, i.e. we need to validate that a validator + was the owner of a given key on a given session, and what the active set ID was + during that session. + + TWOX-NOTE: `SetId` is not under user control. + +```rust +key: U64 +value: U32 +``` + +</details> +</li> + +<li> +<details> +<summary> +<code>Authorities</code> +</summary> + The current list of authorities. + +```rust +value: bounded_collections::weak_bounded_vec::WeakBoundedVec +``` + +</details> +</li> + +</ul> +</li> + +<li>ImOnline - 17 +<ul> + +<li> +<details> +<summary> +<code>HeartbeatAfter</code> +</summary> + The block number after which it's ok to send heartbeats in the current + session. + + At the beginning of each session we set this to a value that should fall + roughly in the middle of the session duration. The idea is to first wait for + the validators to produce a block in the current session, so that the + heartbeat later on will not be necessary. + + This value will only be used as a fallback if we fail to get a proper session + progress estimate from `NextSessionRotation`, as those estimates should be + more accurate then the value we calculate for `HeartbeatAfter`. + +```rust +value: U32 +``` + +</details> +</li> + +<li> +<details> +<summary> +<code>Keys</code> +</summary> + The current set of keys that may issue a heartbeat. + +```rust +value: bounded_collections::weak_bounded_vec::WeakBoundedVec +``` + +</details> +</li> + +<li> +<details> +<summary> +<code>ReceivedHeartbeats</code> +</summary> + For each session index, we keep a mapping of `SessionIndex` and `AuthIndex`. + +```rust +value: Bool +``` + +</details> +</li> + +<li> +<details> +<summary> +<code>AuthoredBlocks</code> +</summary> + For each session index, we keep a mapping of `ValidatorId<T>` to the + number of blocks authored by the given authority. + +```rust +value: U32 +``` + +</details> +</li> + +</ul> +</li> + +<li>AuthorityDiscovery - 18 +<ul> + +<li> +<details> +<summary> +<code>Keys</code> +</summary> + Keys of the current authority set. + +```rust +value: bounded_collections::weak_bounded_vec::WeakBoundedVec +``` + +</details> +</li> + +<li> +<details> +<summary> +<code>NextKeys</code> +</summary> + Keys of the next authority set. + +```rust +value: bounded_collections::weak_bounded_vec::WeakBoundedVec +``` + +</details> +</li> + +</ul> +</li> + +<li>Sudo - 20 +<ul> + +<li> +<details> +<summary> +<code>Key</code> +</summary> + The `AccountId` of the sudo key. + +```rust +value: sp_core::crypto::AccountId32 +``` + +</details> +</li> + +</ul> +</li> + +<li>UpgradeOrigin - 21 +<ul> + +</ul> +</li> + +<li>Preimage - 22 +<ul> + +<li> +<details> +<summary> +<code>StatusFor</code> +</summary> + The request status of a given hash. + +```rust +key: primitive_types::H256 +value: pallet_preimage::OldRequestStatus +``` + +</details> +</li> + +<li> +<details> +<summary> +<code>RequestStatusFor</code> +</summary> + The request status of a given hash. + +```rust +key: primitive_types::H256 +value: pallet_preimage::RequestStatus +``` + +</details> +</li> + +<li> +<details> +<summary> +<code>PreimageFor</code> +</summary> + + +```rust +value: bounded_collections::bounded_vec::BoundedVec +``` + +</details> +</li> + +</ul> +</li> + +<li>TechnicalCommittee - 23 +<ul> + +<li> +<details> +<summary> +<code>Proposals</code> +</summary> + The hashes of the active proposals. + +```rust +value: bounded_collections::bounded_vec::BoundedVec +``` + +</details> +</li> + +<li> +<details> +<summary> +<code>ProposalOf</code> +</summary> + Actual proposal for a given hash, if it's current. + +```rust +key: primitive_types::H256 +value: gdev_runtime::RuntimeCall +``` + +</details> +</li> + +<li> +<details> +<summary> +<code>Voting</code> +</summary> + Votes on a given proposal, if it is ongoing. + +```rust +key: primitive_types::H256 +value: pallet_collective::Votes +``` + +</details> +</li> + +<li> +<details> +<summary> +<code>ProposalCount</code> +</summary> + Proposals so far. + +```rust +value: U32 +``` + +</details> +</li> + +<li> +<details> +<summary> +<code>Members</code> +</summary> + The current members of the collective. This is stored sorted (just by value). + + + +</details> +</li> + +<li> +<details> +<summary> +<code>Prime</code> +</summary> + The prime member that helps determine the default vote behavior in case of abstentions. + +```rust +value: sp_core::crypto::AccountId32 +``` + +</details> +</li> + +</ul> +</li> + +<li>UniversalDividend - 30 +<ul> + +<li> +<details> +<summary> +<code>CurrentUd</code> +</summary> + The current Universal Dividend value. + +```rust +value: U64 +``` + +</details> +</li> + +<li> +<details> +<summary> +<code>CurrentUdIndex</code> +</summary> + The current Universal Dividend index. + +```rust +value: U16 +``` + +</details> +</li> + +<li> +<details> +<summary> +<code>MonetaryMass</code> +</summary> + The total quantity of money created by Universal Dividend, excluding potential money destruction. + +```rust +value: U64 +``` + +</details> +</li> + +<li> +<details> +<summary> +<code>NextReeval</code> +</summary> + The next Universal Dividend re-evaluation. + +```rust +value: U64 +``` + +</details> +</li> + +<li> +<details> +<summary> +<code>NextUd</code> +</summary> + The next Universal Dividend creation. + +```rust +value: U64 +``` + +</details> +</li> + +<li> +<details> +<summary> +<code>PastReevals</code> +</summary> + The past Universal Dividend re-evaluations. + +```rust +value: bounded_collections::bounded_vec::BoundedVec +``` + +</details> +</li> + +</ul> +</li> + +<li>Wot - 40 +<ul> + +</ul> +</li> + +<li>Identity - 41 +<ul> + +<li> +<details> +<summary> +<code>Identities</code> +</summary> + The identity value for each identity. + +```rust +key: U32 +value: pallet_identity::types::IdtyValue +``` + +</details> +</li> + +<li> +<details> +<summary> +<code>CounterForIdentities</code> +</summary> +Counter for the related counted storage map + +```rust +value: U32 +``` + +</details> +</li> + +<li> +<details> +<summary> +<code>IdentityIndexOf</code> +</summary> + The identity associated with each account. + +```rust +key: sp_core::crypto::AccountId32 +value: U32 +``` + +</details> +</li> + +<li> +<details> +<summary> +<code>IdentitiesNames</code> +</summary> + The name associated with each identity. + +```rust +key: pallet_identity::types::IdtyName +value: U32 +``` + +</details> +</li> + +<li> +<details> +<summary> +<code>NextIdtyIndex</code> +</summary> + The identity index to assign to the next created identity. + +```rust +value: U32 +``` + +</details> +</li> + +<li> +<details> +<summary> +<code>IdentityChangeSchedule</code> +</summary> + The identities to remove at a given block. + +```rust +key: U32 + +``` + +</details> +</li> + +</ul> +</li> + +<li>Membership - 42 +<ul> + +<li> +<details> +<summary> +<code>Membership</code> +</summary> + The membership data for each identity. + +```rust +key: U32 +value: sp_membership::MembershipData +``` + +</details> +</li> + +<li> +<details> +<summary> +<code>CounterForMembership</code> +</summary> +Counter for the related counted storage map + +```rust +value: U32 +``` + +</details> +</li> + +<li> +<details> +<summary> +<code>MembershipsExpireOn</code> +</summary> + The identities of memberships to expire at a given block. + +```rust +key: U32 + +``` + +</details> +</li> + +</ul> +</li> + +<li>Certification - 43 +<ul> + +<li> +<details> +<summary> +<code>StorageIdtyCertMeta</code> +</summary> + The certification metadata for each issuer. + +```rust +key: U32 +value: pallet_certification::types::IdtyCertMeta +``` + +</details> +</li> + +<li> +<details> +<summary> +<code>CertsByReceiver</code> +</summary> + The certifications for each receiver. + +```rust +key: U32 + +``` + +</details> +</li> + +<li> +<details> +<summary> +<code>CertsRemovableOn</code> +</summary> + The certifications that should expire at a given block. + +```rust +key: U32 + +``` + +</details> +</li> + +</ul> +</li> + +<li>Distance - 44 +<ul> + +<li> +<details> +<summary> +<code>EvaluationPool0</code> +</summary> + The first evaluation pool for distance evaluation queuing identities to evaluate for a given + evaluator account. + +```rust +value: pallet_distance::types::EvaluationPool +``` + +</details> +</li> + +<li> +<details> +<summary> +<code>EvaluationPool1</code> +</summary> + The second evaluation pool for distance evaluation queuing identities to evaluate for a given + evaluator account. + +```rust +value: pallet_distance::types::EvaluationPool +``` + +</details> +</li> + +<li> +<details> +<summary> +<code>EvaluationPool2</code> +</summary> + The third evaluation pool for distance evaluation queuing identities to evaluate for a given + evaluator account. + +```rust +value: pallet_distance::types::EvaluationPool +``` + +</details> +</li> + +<li> +<details> +<summary> +<code>EvaluationBlock</code> +</summary> + The block at which the distance is evaluated. + +```rust +value: primitive_types::H256 +``` + +</details> +</li> + +<li> +<details> +<summary> +<code>PendingEvaluationRequest</code> +</summary> + The pending evaluation requesters. + +```rust +key: U32 +value: sp_core::crypto::AccountId32 +``` + +</details> +</li> + +<li> +<details> +<summary> +<code>DidUpdate</code> +</summary> + Store if the evaluation was updated in this block. + +```rust +value: Bool +``` + +</details> +</li> + +<li> +<details> +<summary> +<code>CurrentPeriodIndex</code> +</summary> + The current evaluation period index. + +```rust +value: U32 +``` + +</details> +</li> + +</ul> +</li> + +<li>AtomicSwap - 50 +<ul> + +<li> +<details> +<summary> +<code>PendingSwaps</code> +</summary> + + +```rust +value: pallet_atomic_swap::PendingSwap +``` + +</details> +</li> + +</ul> +</li> + +<li>Multisig - 51 +<ul> + +<li> +<details> +<summary> +<code>Multisigs</code> +</summary> + The set of open multisig operations. + +```rust +value: pallet_multisig::Multisig +``` + +</details> +</li> + +</ul> +</li> + +<li>ProvideRandomness - 52 +<ul> + +<li> +<details> +<summary> +<code>NexEpochHookIn</code> +</summary> + The number of blocks before the next epoch. + +```rust +value: U8 +``` + +</details> +</li> + +<li> +<details> +<summary> +<code>RequestIdProvider</code> +</summary> + The request ID. + +```rust +value: U64 +``` + +</details> +</li> + +<li> +<details> +<summary> +<code>RequestsReadyAtNextBlock</code> +</summary> + The requests that will be fulfilled at the next block. + + + +</details> +</li> + +<li> +<details> +<summary> +<code>RequestsReadyAtEpoch</code> +</summary> + The requests that will be fulfilled at the next epoch. + +```rust +key: U64 + +``` + +</details> +</li> + +<li> +<details> +<summary> +<code>RequestsIds</code> +</summary> + The requests being processed. + +```rust +key: U64 + +``` + +</details> +</li> + +<li> +<details> +<summary> +<code>CounterForRequestsIds</code> +</summary> +Counter for the related counted storage map + +```rust +value: U32 +``` + +</details> +</li> + +</ul> +</li> + +<li>Proxy - 53 +<ul> + +<li> +<details> +<summary> +<code>Proxies</code> +</summary> + The set of account proxies. Maps the account which has delegated to the accounts + which are being delegated to, together with the amount held on deposit. + +```rust +key: sp_core::crypto::AccountId32 + +``` + +</details> +</li> + +<li> +<details> +<summary> +<code>Announcements</code> +</summary> + The announcements made by the proxy (key). + +```rust +key: sp_core::crypto::AccountId32 + +``` + +</details> +</li> + +</ul> +</li> + +<li>Utility - 54 +<ul> + +</ul> +</li> + +<li>Treasury - 55 +<ul> + +<li> +<details> +<summary> +<code>ProposalCount</code> +</summary> + Number of proposals that have been made. + +```rust +value: U32 +``` + +</details> +</li> + +<li> +<details> +<summary> +<code>Proposals</code> +</summary> + Proposals that have been made. + +```rust +key: U32 +value: pallet_treasury::Proposal +``` + +</details> +</li> + +<li> +<details> +<summary> +<code>Deactivated</code> +</summary> + The amount which has been reported as inactive to Currency. + +```rust +value: U64 +``` + +</details> +</li> + +<li> +<details> +<summary> +<code>Approvals</code> +</summary> + Proposal indices that have been approved but not yet awarded. + +```rust +value: bounded_collections::bounded_vec::BoundedVec +``` + +</details> +</li> + +<li> +<details> +<summary> +<code>SpendCount</code> +</summary> + The count of spends that have been made. + +```rust +value: U32 +``` + +</details> +</li> + +<li> +<details> +<summary> +<code>Spends</code> +</summary> + Spends that have been approved and being processed. + +```rust +key: U32 +value: pallet_treasury::SpendStatus +``` + +</details> +</li> + +</ul> +</li> + +</ul> diff --git a/xtask/res/templates/runtime-storages.md b/xtask/res/templates/runtime-storages.md new file mode 100644 index 000000000..995456a6c --- /dev/null +++ b/xtask/res/templates/runtime-storages.md @@ -0,0 +1,28 @@ +# Runtime Storage + +There are **{{ storage_counter }}** storages from **{{ pallets | length }}** pallets. + +<ul> +{% for pallet in pallets %} +<li>{{ pallet.name }} - {{ pallet.index }} +<ul> +{% for storage in pallet.storages %} +<li> +<details> +<summary> +<code>{{ storage.name }}</code> +</summary> +{{ storage.documentation }} + +{% if storage.type_key or storage.type_value %}```rust +{% if storage.type_key %}key: {{ storage.type_key }} +{% endif %}{% if storage.type_value %}value: {{ storage.type_value }}{% endif %} +```{% endif %} + +</details> +</li> +{% endfor %} +</ul> +</li> +{% endfor %} +</ul> diff --git a/xtask/src/gen_doc.rs b/xtask/src/gen_doc.rs index 68d77c611..df6110d5d 100644 --- a/xtask/src/gen_doc.rs +++ b/xtask/src/gen_doc.rs @@ -17,6 +17,7 @@ use anyhow::{bail, Context, Result}; use codec::Decode; use core::hash::Hash; +use frame_metadata::v15::StorageEntryType; use scale_info::form::PortableForm; use serde::Serialize; use std::{ @@ -42,6 +43,7 @@ where const CALLS_DOC_FILEPATH: &str = "docs/api/runtime-calls.md"; const EVENTS_DOC_FILEPATH: &str = "docs/api/runtime-events.md"; +const STORAGES_DOC_FILEPATH: &str = "docs/api/runtime-storages.md"; const ERRORS_DOC_FILEPATH: &str = "docs/api/runtime-errors.md"; const ERRORS_PO_FILEPATH: &str = "docs/api/runtime-errors.po"; const TEMPLATES_GLOB: &str = "xtask/res/templates/*.{md,po}"; @@ -59,6 +61,7 @@ struct Pallet { calls: Vec<Call>, events: Vec<Event>, errors: Vec<ErroR>, + storages: Vec<Storage>, } #[derive(Clone, Serialize)] struct Call { @@ -91,6 +94,13 @@ struct ErroR { index: u8, name: String, } +#[derive(Clone, Serialize)] +struct Storage { + documentation: String, + name: String, + type_key: String, + type_value: String, +} impl Pallet { fn new( @@ -100,6 +110,7 @@ impl Pallet { call_scale_type_def: &Option<scale_info::TypeDef<PortableForm>>, event_scale_type_def: &Option<scale_info::TypeDef<PortableForm>>, error_scale_type_def: &Option<scale_info::TypeDef<PortableForm>>, + storage_scale_type_defs: &Option<Vec<Storage>>, ) -> Result<Self> { let calls = if let Some(call_scale_type_def) = call_scale_type_def { if let scale_info::TypeDef::Variant(calls_enum) = call_scale_type_def { @@ -128,6 +139,14 @@ impl Pallet { } else { vec![] }; + + let storages: Vec<Storage> = storage_scale_type_defs + .clone() + .unwrap_or_else(|| vec![]) + .into_iter() + .map(|i| i.into()) + .collect(); + Ok(Self { index, name, @@ -135,6 +154,7 @@ impl Pallet { calls, events, errors, + storages, }) } } @@ -320,7 +340,7 @@ pub(super) fn gen_doc() -> Result<()> { }) }); - let (call_doc, event_doc, error_doc, error_po) = print_runtime(runtime); + let (call_doc, event_doc, error_doc, error_po, storage_doc) = print_runtime(runtime); // Generate docs from rust code Command::new("cargo") @@ -363,6 +383,10 @@ pub(super) fn gen_doc() -> Result<()> { .with_context(|| format!("Failed to create file '{}'", ERRORS_DOC_FILEPATH))?; file.write_all(error_doc.as_bytes()) .with_context(|| format!("Failed to write to file '{}'", ERRORS_DOC_FILEPATH))?; + let mut file = File::create(STORAGES_DOC_FILEPATH) + .with_context(|| format!("Failed to create file '{}'", STORAGES_DOC_FILEPATH))?; + file.write_all(storage_doc.as_bytes()) + .with_context(|| format!("Failed to write to file '{}'", ERRORS_DOC_FILEPATH))?; let mut file = File::create(ERRORS_PO_FILEPATH) .with_context(|| format!("Failed to create file '{}'", ERRORS_PO_FILEPATH))?; file.write_all(error_po.as_bytes()) @@ -447,6 +471,50 @@ fn get_from_metadata_v15( None }; + let storage_entries: Vec<Storage> = pallet + .storage + .map(|storage| { + storage + .entries + .iter() + .map(|variant| { + let resolve_type = |type_id: u32| -> String { + metadata_v15 + .types + .resolve(type_id) + .map(|resolved| { + let path = resolved.path.to_string(); + if !path.is_empty() { + path + } else if let scale_info::TypeDef::Primitive(v) = + &resolved.type_def + { + format!("{:?}", v) + } else { + String::default() + } + }) + .unwrap_or_default() + }; + match &variant.ty { + StorageEntryType::Map { key, value, .. } => Storage { + documentation: variant.docs.join("\n"), + name: variant.name.clone(), + type_key: resolve_type(key.id), + type_value: resolve_type(value.id), + }, + StorageEntryType::Plain(v) => Storage { + documentation: variant.docs.join("\n"), + name: variant.name.clone(), + type_key: String::default(), + type_value: resolve_type(v.id), + }, + } + }) + .collect() + }) + .unwrap_or_default(); + let pallet = Pallet::new( pallet.index, pallet.name.clone(), @@ -454,6 +522,7 @@ fn get_from_metadata_v15( &calls_type_def, &events_type_def, &errors_type_def, + &Some(storage_entries), )?; println!( @@ -474,6 +543,12 @@ fn get_from_metadata_v15( pallet.name, pallet.errors.len() ); + println!( + "{}: {} ({} storages)", + pallet.index, + pallet.name, + pallet.storages.len() + ); pallets.push(pallet); } Ok(pallets) @@ -488,7 +563,7 @@ fn get_weights(max_weight: u128) -> Result<HashMap<String, HashMap<String, Weigh } /// use template to render markdown file with runtime calls documentation -fn print_runtime(pallets: RuntimePallets) -> (String, String, String, String) { +fn print_runtime(pallets: RuntimePallets) -> (String, String, String, String, String) { // init variables // -- user calls let mut user_calls_counter = 0; @@ -521,6 +596,12 @@ fn print_runtime(pallets: RuntimePallets) -> (String, String, String, String) { .iter() .for_each(|pallet| error_counter += pallet.errors.len()); + // storage counter + let mut storage_counter = 0; + pallets + .iter() + .for_each(|pallet| storage_counter += pallet.storages.len()); + // compile template let tera = match Tera::new(TEMPLATES_GLOB) { Ok(t) => t, @@ -556,5 +637,12 @@ fn print_runtime(pallets: RuntimePallets) -> (String, String, String, String) { .render("runtime-errors.po", &context) .expect("template error"); - (call_doc, event_doc, error_doc, error_po) + // render storages + context.insert("pallets", &pallets); + context.insert("storage_counter", &event_counter); + let storage_doc = tera + .render("runtime-storages.md", &context) + .expect("template storage"); + + (call_doc, event_doc, error_doc, error_po, storage_doc) } -- GitLab From 3dbaee4b949b0b1f54bb60dbfcd5784f897f6559 Mon Sep 17 00:00:00 2001 From: bgallois <benjamin@gallois.cc> Date: Thu, 30 Jan 2025 10:50:19 +0100 Subject: [PATCH 2/7] add constants --- docs/api/runtime-constants.md | 1346 ++++++++++++++++++++++ xtask/res/templates/runtime-constants.md | 28 + xtask/src/gen_doc.rs | 98 +- 3 files changed, 1466 insertions(+), 6 deletions(-) create mode 100644 docs/api/runtime-constants.md create mode 100644 xtask/res/templates/runtime-constants.md diff --git a/docs/api/runtime-constants.md b/docs/api/runtime-constants.md new file mode 100644 index 000000000..765b36e5e --- /dev/null +++ b/docs/api/runtime-constants.md @@ -0,0 +1,1346 @@ +# Runtime Storage + +There are **69** storages from **35** pallets. + +<ul> + +<li>System - 0 +<ul> + +<li> +<details> +<summary> +<code>BlockWeights</code> +</summary> + Block & extrinsics weights: base values and limits. + +```rust +value: { base_block: { ref_time: 453383000, proof_size: 0 }, max_block: { ref_time: 2000000000000, proof_size: 18446744073709551615 }, per_class: { normal: { base_extrinsic: { ref_time: 107074000, proof_size: 0 }, max_extrinsic: Some ({ ref_time: 1299892926000, proof_size: 11990383647911208550 }), max_total: Some ({ ref_time: 1500000000000, proof_size: 13835058055282163711 }), reserved: Some ({ ref_time: 0, proof_size: 0 }) }, operational: { base_extrinsic: { ref_time: 107074000, proof_size: 0 }, max_extrinsic: Some ({ ref_time: 1799892926000, proof_size: 16602069666338596454 }), max_total: Some ({ ref_time: 2000000000000, proof_size: 18446744073709551615 }), reserved: Some ({ ref_time: 500000000000, proof_size: 4611686018427387904 }) }, mandatory: { base_extrinsic: { ref_time: 107074000, proof_size: 0 }, max_extrinsic: None (), max_total: None (), reserved: None () } } } +type: frame_system::limits::BlockWeights +``` + +</details> +</li> + +<li> +<details> +<summary> +<code>BlockLength</code> +</summary> + The maximum length of a block (in bytes). + +```rust +value: { max: { normal: 3932160, operational: 5242880, mandatory: 5242880 } } +type: frame_system::limits::BlockLength +``` + +</details> +</li> + +<li> +<details> +<summary> +<code>BlockHashCount</code> +</summary> + Maximum number of block number to block hash mappings to keep (oldest pruned first). + +```rust +value: 2400 +type: U32 +``` + +</details> +</li> + +<li> +<details> +<summary> +<code>DbWeight</code> +</summary> + The weight of runtime database operations the runtime can invoke. + +```rust +value: { read: 21040000, write: 104032000 } +type: sp_weights::RuntimeDbWeight +``` + +</details> +</li> + +<li> +<details> +<summary> +<code>Version</code> +</summary> + Get the chain's in-code version. + +```rust +value: { spec_name: "gdev", impl_name: "duniter-gdev", authoring_version: 1, spec_version: 800, impl_version: 1, apis: ((((104, 122, 212, 74, 211, 127, 3, 194), 1), ((203, 202, 37, 227, 159, 20, 35, 135), 2), ((223, 106, 203, 104, 153, 7, 96, 155), 5), ((55, 227, 151, 252, 124, 145, 245, 228), 2), ((64, 254, 58, 212, 1, 248, 149, 154), 6), ((210, 188, 152, 151, 238, 208, 143, 21), 3), ((247, 139, 39, 139, 229, 63, 69, 76), 2), ((171, 60, 5, 114, 41, 31, 235, 139), 1), ((237, 153, 197, 172, 178, 94, 237, 245), 3), ((188, 157, 137, 144, 79, 91, 146, 63), 1), ((55, 200, 187, 19, 80, 169, 162, 168), 4), ((251, 197, 119, 185, 215, 71, 239, 214), 1))), transaction_version: 1, state_version: 1 } +type: sp_version::RuntimeVersion +``` + +</details> +</li> + +<li> +<details> +<summary> +<code>SS58Prefix</code> +</summary> + The designated SS58 prefix of this chain. + + This replaces the "ss58Format" property declared in the chain spec. Reason is + that the runtime should know about the prefix in order to make use of it as + an identifier of the chain. + +```rust +value: 42 +type: U16 +``` + +</details> +</li> + +</ul> +</li> + +<li>Account - 1 +<ul> + +</ul> +</li> + +<li>Scheduler - 2 +<ul> + +<li> +<details> +<summary> +<code>MaximumWeight</code> +</summary> + The maximum weight that may be scheduled per block for any dispatchables. + +```rust +value: { ref_time: 1600000000000, proof_size: 14757395258967641292 } +type: sp_weights::weight_v2::Weight +``` + +</details> +</li> + +<li> +<details> +<summary> +<code>MaxScheduledPerBlock</code> +</summary> + The maximum number of scheduled calls in the queue for a single block. + + NOTE: + + Dependent pallets' benchmarks might require a higher limit for the setting. Set a + higher limit under `runtime-benchmarks` feature. + +```rust +value: 50 +type: U32 +``` + +</details> +</li> + +</ul> +</li> + +<li>Babe - 3 +<ul> + +<li> +<details> +<summary> +<code>EpochDuration</code> +</summary> + The amount of time, in slots, that each epoch should last. + NOTE: Currently it is not possible to change the epoch duration after + the chain has started. Attempting to do so will brick block production. + +```rust +value: 30 +type: U64 +``` + +</details> +</li> + +<li> +<details> +<summary> +<code>ExpectedBlockTime</code> +</summary> + The expected average block time at which BABE should be creating + blocks. Since BABE is probabilistic it is not trivial to figure out + what the expected average block time should be based on the slot + duration and the security parameter `c` (where `1 - c` represents + the probability of a slot being empty). + +```rust +value: 6000 +type: U64 +``` + +</details> +</li> + +<li> +<details> +<summary> +<code>MaxAuthorities</code> +</summary> + Max number of authorities allowed + +```rust +value: 32 +type: U32 +``` + +</details> +</li> + +<li> +<details> +<summary> +<code>MaxNominators</code> +</summary> + The maximum number of nominators for each validator. + +```rust +value: 64 +type: U32 +``` + +</details> +</li> + +</ul> +</li> + +<li>Timestamp - 4 +<ul> + +<li> +<details> +<summary> +<code>MinimumPeriod</code> +</summary> + The minimum period between blocks. + + Be aware that this is different to the *expected* period that the block production + apparatus provides. Your chosen consensus system will generally work with this to + determine a sensible block time. For example, in the Aura pallet it will be double this + period on default settings. + +```rust +value: 3000 +type: U64 +``` + +</details> +</li> + +</ul> +</li> + +<li>Parameters - 5 +<ul> + +</ul> +</li> + +<li>Balances - 6 +<ul> + +<li> +<details> +<summary> +<code>ExistentialDeposit</code> +</summary> + The minimum amount required to keep an account open. MUST BE GREATER THAN ZERO! + + If you *really* need it to be zero, you can enable the feature `insecure_zero_ed` for + this pallet. However, you do so at your own risk: this will open up a major DoS vector. + In case you have multiple sources of provider references, you may also get unexpected + behaviour if you set this to zero. + + Bottom line: Do yourself a favour and make it at least one! + +```rust +value: 100 +type: U64 +``` + +</details> +</li> + +<li> +<details> +<summary> +<code>MaxLocks</code> +</summary> + The maximum number of locks that should exist on an account. + Not strictly enforced, but used for weight estimation. + + Use of locks is deprecated in favour of freezes. See `https://github.com/paritytech/substrate/pull/12951/` + +```rust +value: 50 +type: U32 +``` + +</details> +</li> + +<li> +<details> +<summary> +<code>MaxReserves</code> +</summary> + The maximum number of named reserves that can exist on an account. + + Use of reserves is deprecated in favour of holds. See `https://github.com/paritytech/substrate/pull/12951/` + +```rust +value: 5 +type: U32 +``` + +</details> +</li> + +<li> +<details> +<summary> +<code>MaxFreezes</code> +</summary> + The maximum number of individual freeze locks that can exist on an account at any time. + +```rust +value: 0 +type: U32 +``` + +</details> +</li> + +</ul> +</li> + +<li>TransactionPayment - 32 +<ul> + +<li> +<details> +<summary> +<code>OperationalFeeMultiplier</code> +</summary> + A fee multiplier for `Operational` extrinsics to compute "virtual tip" to boost their + `priority` + + This value is multiplied by the `final_fee` to obtain a "virtual tip" that is later + added to a tip component in regular `priority` calculations. + It means that a `Normal` transaction can front-run a similarly-sized `Operational` + extrinsic (with no tip), by including a tip value greater than the virtual tip. + + ```rust,ignore + // For `Normal` + let priority = priority_calc(tip); + + // For `Operational` + let virtual_tip = (inclusion_fee + tip) * OperationalFeeMultiplier; + let priority = priority_calc(tip + virtual_tip); + ``` + + Note that since we use `final_fee` the multiplier applies also to the regular `tip` + sent with the transaction. So, not only does the transaction get a priority bump based + on the `inclusion_fee`, but we also amplify the impact of tips applied to `Operational` + transactions. + +```rust +value: 5 +type: U8 +``` + +</details> +</li> + +</ul> +</li> + +<li>OneshotAccount - 7 +<ul> + +</ul> +</li> + +<li>Quota - 66 +<ul> + +<li> +<details> +<summary> +<code>RefundAccount</code> +</summary> + Account used to refund fees. + +```rust +value: ((109, 111, 100, 108, 112, 121, 47, 116, 114, 115, 114, 121, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)) +type: sp_core::crypto::AccountId32 +``` + +</details> +</li> + +</ul> +</li> + +<li>SmithMembers - 10 +<ul> + +<li> +<details> +<summary> +<code>MaxByIssuer</code> +</summary> + Maximum number of active certifications per issuer. + +```rust +value: 8 +type: U32 +``` + +</details> +</li> + +<li> +<details> +<summary> +<code>MinCertForMembership</code> +</summary> + Minimum number of certifications required to become a Smith. + +```rust +value: 2 +type: U32 +``` + +</details> +</li> + +<li> +<details> +<summary> +<code>SmithInactivityMaxDuration</code> +</summary> + Maximum duration of inactivity allowed before a Smith is removed. + +```rust +value: 48 +type: U32 +``` + +</details> +</li> + +</ul> +</li> + +<li>AuthorityMembers - 11 +<ul> + +<li> +<details> +<summary> +<code>MaxAuthorities</code> +</summary> + Maximum number of authorities allowed. + +```rust +value: 32 +type: U32 +``` + +</details> +</li> + +</ul> +</li> + +<li>Authorship - 12 +<ul> + +</ul> +</li> + +<li>Offences - 13 +<ul> + +</ul> +</li> + +<li>Historical - 14 +<ul> + +</ul> +</li> + +<li>Session - 15 +<ul> + +</ul> +</li> + +<li>Grandpa - 16 +<ul> + +<li> +<details> +<summary> +<code>MaxAuthorities</code> +</summary> + Max Authorities in use + +```rust +value: 32 +type: U32 +``` + +</details> +</li> + +<li> +<details> +<summary> +<code>MaxNominators</code> +</summary> + The maximum number of nominators for each validator. + +```rust +value: 64 +type: U32 +``` + +</details> +</li> + +<li> +<details> +<summary> +<code>MaxSetIdSessionEntries</code> +</summary> + The maximum number of entries to keep in the set id to session index mapping. + + Since the `SetIdSession` map is only used for validating equivocations this + value should relate to the bonding duration of whatever staking system is + being used (if any). If equivocation handling is not enabled then this value + can be zero. + +```rust +value: 1000 +type: U64 +``` + +</details> +</li> + +</ul> +</li> + +<li>ImOnline - 17 +<ul> + +<li> +<details> +<summary> +<code>UnsignedPriority</code> +</summary> + A configuration for base priority of unsigned transactions. + + This is exposed so that it can be tuned for particular runtime, when + multiple pallets send unsigned transactions. + +```rust +value: 18446744073709551615 +type: U64 +``` + +</details> +</li> + +</ul> +</li> + +<li>AuthorityDiscovery - 18 +<ul> + +</ul> +</li> + +<li>Sudo - 20 +<ul> + +</ul> +</li> + +<li>UpgradeOrigin - 21 +<ul> + +</ul> +</li> + +<li>Preimage - 22 +<ul> + +</ul> +</li> + +<li>TechnicalCommittee - 23 +<ul> + +<li> +<details> +<summary> +<code>MaxProposalWeight</code> +</summary> + The maximum weight of a dispatch call that can be proposed and executed. + +```rust +value: { ref_time: 1000000000000, proof_size: 9223372036854775807 } +type: sp_weights::weight_v2::Weight +``` + +</details> +</li> + +</ul> +</li> + +<li>UniversalDividend - 30 +<ul> + +<li> +<details> +<summary> +<code>MaxPastReeval</code> +</summary> + Maximum number of past UD revaluations to keep in storage. + +```rust +value: 160 +type: U32 +``` + +</details> +</li> + +<li> +<details> +<summary> +<code>SquareMoneyGrowthRate</code> +</summary> + Square of the money growth rate per UD reevaluation period. + +```rust +value: (2381440) +type: sp_arithmetic::per_things::Perbill +``` + +</details> +</li> + +<li> +<details> +<summary> +<code>UdCreationPeriod</code> +</summary> + Universal dividend creation period in milliseconds. + +```rust +value: 60000 +type: U64 +``` + +</details> +</li> + +<li> +<details> +<summary> +<code>UdReevalPeriod</code> +</summary> + Universal dividend reevaluation period in milliseconds. + +```rust +value: 1200000 +type: U64 +``` + +</details> +</li> + +</ul> +</li> + +<li>Wot - 40 +<ul> + +<li> +<details> +<summary> +<code>FirstIssuableOn</code> +</summary> + The block number from which the first certification can be issued. + +```rust +value: 20 +type: U32 +``` + +</details> +</li> + +<li> +<details> +<summary> +<code>MinCertForMembership</code> +</summary> + The minimum number of certifications required for membership eligibility. + +```rust +value: 2 +type: U32 +``` + +</details> +</li> + +<li> +<details> +<summary> +<code>MinCertForCreateIdtyRight</code> +</summary> + The minimum number of certifications required to create an identity. + +```rust +value: 2 +type: U32 +``` + +</details> +</li> + +</ul> +</li> + +<li>Identity - 41 +<ul> + +<li> +<details> +<summary> +<code>ConfirmPeriod</code> +</summary> + The period during which the owner can confirm the new identity. + +```rust +value: 40 +type: U32 +``` + +</details> +</li> + +<li> +<details> +<summary> +<code>ValidationPeriod</code> +</summary> + The period during which the identity has to be validated to become a member. + +```rust +value: 876600 +type: U32 +``` + +</details> +</li> + +<li> +<details> +<summary> +<code>AutorevocationPeriod</code> +</summary> + The period before which an identity that lost membership is automatically revoked. + +```rust +value: 438300 +type: U32 +``` + +</details> +</li> + +<li> +<details> +<summary> +<code>DeletionPeriod</code> +</summary> + The period after which a revoked identity is removed and the keys are freed. + +```rust +value: 438300 +type: U32 +``` + +</details> +</li> + +<li> +<details> +<summary> +<code>ChangeOwnerKeyPeriod</code> +</summary> + The minimum duration between two owner key changes to prevent identity theft. + +```rust +value: 100800 +type: U32 +``` + +</details> +</li> + +<li> +<details> +<summary> +<code>IdtyCreationPeriod</code> +</summary> + The minimum duration between the creation of two identities by the same creator. + Should be greater than or equal to the certification period defined in the certification pallet. + +```rust +value: 50 +type: U32 +``` + +</details> +</li> + +</ul> +</li> + +<li>Membership - 42 +<ul> + +<li> +<details> +<summary> +<code>MembershipPeriod</code> +</summary> + Maximum lifespan of a single membership (in number of blocks). + +```rust +value: 1000 +type: U32 +``` + +</details> +</li> + +<li> +<details> +<summary> +<code>MembershipRenewalPeriod</code> +</summary> + Minimum delay to wait before renewing membership, i.e., asking for distance evaluation. + +```rust +value: 1000 +type: U32 +``` + +</details> +</li> + +</ul> +</li> + +<li>Certification - 43 +<ul> + +<li> +<details> +<summary> +<code>CertPeriod</code> +</summary> + The minimum duration (in blocks) between two certifications issued by the same issuer. + +```rust +value: 15 +type: U32 +``` + +</details> +</li> + +<li> +<details> +<summary> +<code>MaxByIssuer</code> +</summary> + The maximum number of active certifications that can be issued by a single issuer. + +```rust +value: 10 +type: U32 +``` + +</details> +</li> + +<li> +<details> +<summary> +<code>MinReceivedCertToBeAbleToIssueCert</code> +</summary> + The minimum number of certifications received that an identity must have + to be allowed to issue a certification. + +```rust +value: 2 +type: U32 +``` + +</details> +</li> + +<li> +<details> +<summary> +<code>ValidityPeriod</code> +</summary> + The duration (in blocks) for which a certification remains valid. + +```rust +value: 1000 +type: U32 +``` + +</details> +</li> + +</ul> +</li> + +<li>Distance - 44 +<ul> + +<li> +<details> +<summary> +<code>EvaluationPrice</code> +</summary> + The amount reserved during evaluation. + +```rust +value: 1000 +type: U64 +``` + +</details> +</li> + +<li> +<details> +<summary> +<code>EvaluationPeriod</code> +</summary> + The evaluation period in blocks. + Since the evaluation uses 3 pools, the total evaluation time will be 3 * EvaluationPeriod. + +```rust +value: 7 +type: U32 +``` + +</details> +</li> + +<li> +<details> +<summary> +<code>MaxRefereeDistance</code> +</summary> + The maximum distance used to define a referee's accessibility. + This value is not used by the runtime but is needed by the client distance oracle. + +```rust +value: 5 +type: U32 +``` + +</details> +</li> + +<li> +<details> +<summary> +<code>MinAccessibleReferees</code> +</summary> + The minimum ratio of accessible referees required. + +```rust +value: (800000000) +type: sp_arithmetic::per_things::Perbill +``` + +</details> +</li> + +</ul> +</li> + +<li>AtomicSwap - 50 +<ul> + +<li> +<details> +<summary> +<code>ProofLimit</code> +</summary> + Limit of proof size. + + Atomic swap is only atomic if once the proof is revealed, both parties can submit the + proofs on-chain. If A is the one that generates the proof, then it requires that either: + - A's blockchain has the same proof length limit as B's blockchain. + - Or A's blockchain has shorter proof length limit as B's blockchain. + + If B sees A is on a blockchain with larger proof length limit, then it should kindly + refuse to accept the atomic swap request if A generates the proof, and asks that B + generates the proof instead. + +```rust +value: 1024 +type: U32 +``` + +</details> +</li> + +</ul> +</li> + +<li>Multisig - 51 +<ul> + +<li> +<details> +<summary> +<code>DepositBase</code> +</summary> + The base amount of currency needed to reserve for creating a multisig execution or to + store a dispatch call for later. + + This is held for an additional storage item whose value size is + `4 + sizeof((BlockNumber, Balance, AccountId))` bytes and whose key size is + `32 + sizeof(AccountId)` bytes. + +```rust +value: 100 +type: U64 +``` + +</details> +</li> + +<li> +<details> +<summary> +<code>DepositFactor</code> +</summary> + The amount of currency needed per unit threshold when creating a multisig execution. + + This is held for adding 32 bytes more into a pre-existing storage value. + +```rust +value: 32 +type: U64 +``` + +</details> +</li> + +<li> +<details> +<summary> +<code>MaxSignatories</code> +</summary> + The maximum amount of signatories allowed in the multisig. + +```rust +value: 10 +type: U32 +``` + +</details> +</li> + +</ul> +</li> + +<li>ProvideRandomness - 52 +<ul> + +<li> +<details> +<summary> +<code>MaxRequests</code> +</summary> + Maximum number of not yet filled requests. + +```rust +value: 100 +type: U32 +``` + +</details> +</li> + +<li> +<details> +<summary> +<code>RequestPrice</code> +</summary> + The price of a request. + +```rust +value: 2000 +type: U64 +``` + +</details> +</li> + +</ul> +</li> + +<li>Proxy - 53 +<ul> + +<li> +<details> +<summary> +<code>ProxyDepositBase</code> +</summary> + The base amount of currency needed to reserve for creating a proxy. + + This is held for an additional storage item whose value size is + `sizeof(Balance)` bytes and whose key size is `sizeof(AccountId)` bytes. + +```rust +value: 108 +type: U64 +``` + +</details> +</li> + +<li> +<details> +<summary> +<code>ProxyDepositFactor</code> +</summary> + The amount of currency needed per proxy added. + + This is held for adding 32 bytes plus an instance of `ProxyType` more into a + pre-existing storage value. Thus, when configuring `ProxyDepositFactor` one should take + into account `32 + proxy_type.encode().len()` bytes of data. + +```rust +value: 33 +type: U64 +``` + +</details> +</li> + +<li> +<details> +<summary> +<code>MaxProxies</code> +</summary> + The maximum amount of proxies allowed for a single account. + +```rust +value: 32 +type: U32 +``` + +</details> +</li> + +<li> +<details> +<summary> +<code>MaxPending</code> +</summary> + The maximum amount of time-delayed announcements that are allowed to be pending. + +```rust +value: 32 +type: U32 +``` + +</details> +</li> + +<li> +<details> +<summary> +<code>AnnouncementDepositBase</code> +</summary> + The base amount of currency needed to reserve for creating an announcement. + + This is held when a new storage item holding a `Balance` is created (typically 16 + bytes). + +```rust +value: 108 +type: U64 +``` + +</details> +</li> + +<li> +<details> +<summary> +<code>AnnouncementDepositFactor</code> +</summary> + The amount of currency needed per announcement made. + + This is held for adding an `AccountId`, `Hash` and `BlockNumber` (typically 68 bytes) + into a pre-existing storage value. + +```rust +value: 66 +type: U64 +``` + +</details> +</li> + +</ul> +</li> + +<li>Utility - 54 +<ul> + +<li> +<details> +<summary> +<code>batched_calls_limit</code> +</summary> + The limit on the number of batched calls. + +```rust +value: 10922 +type: U32 +``` + +</details> +</li> + +</ul> +</li> + +<li>Treasury - 55 +<ul> + +<li> +<details> +<summary> +<code>SpendPeriod</code> +</summary> + Period between successive spends. + +```rust +value: 14400 +type: U32 +``` + +</details> +</li> + +<li> +<details> +<summary> +<code>Burn</code> +</summary> + Percentage of spare funds (if any) that are burnt per spend period. + +```rust +value: (0) +type: sp_arithmetic::per_things::Permill +``` + +</details> +</li> + +<li> +<details> +<summary> +<code>PalletId</code> +</summary> + The treasury's pallet id, used for deriving its sovereign account ID. + +```rust +value: ((112, 121, 47, 116, 114, 115, 114, 121)) +type: frame_support::PalletId +``` + +</details> +</li> + +<li> +<details> +<summary> +<code>MaxApprovals</code> +</summary> + The maximum number of approvals that can wait in the spending queue. + + NOTE: This parameter is also used within the Bounties Pallet extension if enabled. + +```rust +value: 100 +type: U32 +``` + +</details> +</li> + +<li> +<details> +<summary> +<code>PayoutPeriod</code> +</summary> + The period during which an approved treasury spend has to be claimed. + +```rust +value: 10 +type: U32 +``` + +</details> +</li> + +</ul> +</li> + +</ul> diff --git a/xtask/res/templates/runtime-constants.md b/xtask/res/templates/runtime-constants.md new file mode 100644 index 000000000..6b62b16a2 --- /dev/null +++ b/xtask/res/templates/runtime-constants.md @@ -0,0 +1,28 @@ +# Runtime Storage + +There are **{{ constant_counter }}** storages from **{{ pallets | length }}** pallets. + +<ul> +{% for pallet in pallets %} +<li>{{ pallet.name }} - {{ pallet.index }} +<ul> +{% for constant in pallet.constants %} +<li> +<details> +<summary> +<code>{{ constant.name }}</code> +</summary> +{{ constant.documentation }} + +```rust +value: {{ constant.value }} +type: {{ constant.type_value }} +``` + +</details> +</li> +{% endfor %} +</ul> +</li> +{% endfor %} +</ul> diff --git a/xtask/src/gen_doc.rs b/xtask/src/gen_doc.rs index df6110d5d..63ffe6417 100644 --- a/xtask/src/gen_doc.rs +++ b/xtask/src/gen_doc.rs @@ -44,6 +44,7 @@ where const CALLS_DOC_FILEPATH: &str = "docs/api/runtime-calls.md"; const EVENTS_DOC_FILEPATH: &str = "docs/api/runtime-events.md"; const STORAGES_DOC_FILEPATH: &str = "docs/api/runtime-storages.md"; +const CONSTANTS_DOC_FILEPATH: &str = "docs/api/runtime-constants.md"; const ERRORS_DOC_FILEPATH: &str = "docs/api/runtime-errors.md"; const ERRORS_PO_FILEPATH: &str = "docs/api/runtime-errors.po"; const TEMPLATES_GLOB: &str = "xtask/res/templates/*.{md,po}"; @@ -62,6 +63,7 @@ struct Pallet { events: Vec<Event>, errors: Vec<ErroR>, storages: Vec<Storage>, + constants: Vec<Constant>, } #[derive(Clone, Serialize)] struct Call { @@ -101,6 +103,13 @@ struct Storage { type_key: String, type_value: String, } +#[derive(Clone, Serialize)] +struct Constant { + documentation: String, + name: String, + value: String, + type_value: String, +} impl Pallet { fn new( @@ -111,6 +120,7 @@ impl Pallet { event_scale_type_def: &Option<scale_info::TypeDef<PortableForm>>, error_scale_type_def: &Option<scale_info::TypeDef<PortableForm>>, storage_scale_type_defs: &Option<Vec<Storage>>, + constant_scale_type_defs: &Option<Vec<Constant>>, ) -> Result<Self> { let calls = if let Some(call_scale_type_def) = call_scale_type_def { if let scale_info::TypeDef::Variant(calls_enum) = call_scale_type_def { @@ -147,6 +157,13 @@ impl Pallet { .map(|i| i.into()) .collect(); + let constants: Vec<Constant> = constant_scale_type_defs + .clone() + .unwrap_or_else(|| vec![]) + .into_iter() + .map(|i| i.into()) + .collect(); + Ok(Self { index, name, @@ -155,6 +172,7 @@ impl Pallet { events, errors, storages, + constants, }) } } @@ -340,7 +358,8 @@ pub(super) fn gen_doc() -> Result<()> { }) }); - let (call_doc, event_doc, error_doc, error_po, storage_doc) = print_runtime(runtime); + let (call_doc, event_doc, error_doc, error_po, storage_doc, constant_doc) = + print_runtime(runtime); // Generate docs from rust code Command::new("cargo") @@ -386,7 +405,11 @@ pub(super) fn gen_doc() -> Result<()> { let mut file = File::create(STORAGES_DOC_FILEPATH) .with_context(|| format!("Failed to create file '{}'", STORAGES_DOC_FILEPATH))?; file.write_all(storage_doc.as_bytes()) - .with_context(|| format!("Failed to write to file '{}'", ERRORS_DOC_FILEPATH))?; + .with_context(|| format!("Failed to write to file '{}'", STORAGES_DOC_FILEPATH))?; + let mut file = File::create(CONSTANTS_DOC_FILEPATH) + .with_context(|| format!("Failed to create file '{}'", CONSTANTS_DOC_FILEPATH))?; + file.write_all(constant_doc.as_bytes()) + .with_context(|| format!("Failed to write to file '{}'", CONSTANTS_DOC_FILEPATH))?; let mut file = File::create(ERRORS_PO_FILEPATH) .with_context(|| format!("Failed to create file '{}'", ERRORS_PO_FILEPATH))?; file.write_all(error_po.as_bytes()) @@ -471,7 +494,7 @@ fn get_from_metadata_v15( None }; - let storage_entries: Vec<Storage> = pallet + let storages: Vec<Storage> = pallet .storage .map(|storage| { storage @@ -515,6 +538,42 @@ fn get_from_metadata_v15( }) .unwrap_or_default(); + let constants: Vec<Constant> = pallet + .constants + .iter() + .map(|i| { + let resolve_type = |type_id: u32| -> String { + metadata_v15 + .types + .resolve(type_id) + .map(|resolved| { + let path = resolved.path.to_string(); + if !path.is_empty() { + path + } else if let scale_info::TypeDef::Primitive(v) = &resolved.type_def { + format!("{:?}", v) + } else { + String::default() + } + }) + .unwrap_or_default() + }; + + let decode_value = |value: &Vec<u8>, type_id: u32| -> String { + scale_value::scale::decode_as_type(&mut &**value, &type_id, &metadata_v15.types) + .map(|v| v.to_string()) + .unwrap_or_default() + }; + + Constant { + documentation: i.docs.join("\n"), + name: i.name.clone(), + value: decode_value(&i.value, i.ty.id), + type_value: resolve_type(i.ty.id), + } + }) + .collect(); + let pallet = Pallet::new( pallet.index, pallet.name.clone(), @@ -522,7 +581,8 @@ fn get_from_metadata_v15( &calls_type_def, &events_type_def, &errors_type_def, - &Some(storage_entries), + &Some(storages), + &Some(constants), )?; println!( @@ -549,6 +609,12 @@ fn get_from_metadata_v15( pallet.name, pallet.storages.len() ); + println!( + "{}: {} ({} constants)", + pallet.index, + pallet.name, + pallet.constants.len() + ); pallets.push(pallet); } Ok(pallets) @@ -563,7 +629,7 @@ fn get_weights(max_weight: u128) -> Result<HashMap<String, HashMap<String, Weigh } /// use template to render markdown file with runtime calls documentation -fn print_runtime(pallets: RuntimePallets) -> (String, String, String, String, String) { +fn print_runtime(pallets: RuntimePallets) -> (String, String, String, String, String, String) { // init variables // -- user calls let mut user_calls_counter = 0; @@ -602,6 +668,12 @@ fn print_runtime(pallets: RuntimePallets) -> (String, String, String, String, St .iter() .for_each(|pallet| storage_counter += pallet.storages.len()); + // constant counter + let mut constant_counter = 0; + pallets + .iter() + .for_each(|pallet| constant_counter += pallet.constants.len()); + // compile template let tera = match Tera::new(TEMPLATES_GLOB) { Ok(t) => t, @@ -644,5 +716,19 @@ fn print_runtime(pallets: RuntimePallets) -> (String, String, String, String, St .render("runtime-storages.md", &context) .expect("template storage"); - (call_doc, event_doc, error_doc, error_po, storage_doc) + // render constant + context.insert("pallets", &pallets); + context.insert("constant_counter", &constant_counter); + let constant_doc = tera + .render("runtime-constants.md", &context) + .expect("template constant"); + + ( + call_doc, + event_doc, + error_doc, + error_po, + storage_doc, + constant_doc, + ) } -- GitLab From 1a87e3f0a5680be5cfa619893201ed22c2536c33 Mon Sep 17 00:00:00 2001 From: bgallois <benjamin@gallois.cc> Date: Thu, 30 Jan 2025 11:06:58 +0100 Subject: [PATCH 3/7] refactoring --- xtask/src/gen_doc.rs | 23 +++++------------------ 1 file changed, 5 insertions(+), 18 deletions(-) diff --git a/xtask/src/gen_doc.rs b/xtask/src/gen_doc.rs index 63ffe6417..5b56bf95a 100644 --- a/xtask/src/gen_doc.rs +++ b/xtask/src/gen_doc.rs @@ -112,6 +112,7 @@ struct Constant { } impl Pallet { + #![allow(clippy::too_many_arguments)] fn new( index: u8, name: String, @@ -119,8 +120,8 @@ impl Pallet { call_scale_type_def: &Option<scale_info::TypeDef<PortableForm>>, event_scale_type_def: &Option<scale_info::TypeDef<PortableForm>>, error_scale_type_def: &Option<scale_info::TypeDef<PortableForm>>, - storage_scale_type_defs: &Option<Vec<Storage>>, - constant_scale_type_defs: &Option<Vec<Constant>>, + storages: Vec<Storage>, + constants: Vec<Constant>, ) -> Result<Self> { let calls = if let Some(call_scale_type_def) = call_scale_type_def { if let scale_info::TypeDef::Variant(calls_enum) = call_scale_type_def { @@ -150,20 +151,6 @@ impl Pallet { vec![] }; - let storages: Vec<Storage> = storage_scale_type_defs - .clone() - .unwrap_or_else(|| vec![]) - .into_iter() - .map(|i| i.into()) - .collect(); - - let constants: Vec<Constant> = constant_scale_type_defs - .clone() - .unwrap_or_else(|| vec![]) - .into_iter() - .map(|i| i.into()) - .collect(); - Ok(Self { index, name, @@ -581,8 +568,8 @@ fn get_from_metadata_v15( &calls_type_def, &events_type_def, &errors_type_def, - &Some(storages), - &Some(constants), + storages, + constants, )?; println!( -- GitLab From 497ac155a4b347c5a056d4df88c0ade31a9d0a75 Mon Sep 17 00:00:00 2001 From: bgallois <benjamin@gallois.cc> Date: Thu, 30 Jan 2025 17:16:55 +0100 Subject: [PATCH 4/7] better type formatting --- docs/api/runtime-constants.md | 211 ++++++++-------------- docs/api/runtime-storages.md | 219 ++++++++++++++--------- xtask/res/templates/runtime-constants.md | 7 +- xtask/src/gen_doc.rs | 100 ++++++++--- 4 files changed, 280 insertions(+), 257 deletions(-) diff --git a/docs/api/runtime-constants.md b/docs/api/runtime-constants.md index 765b36e5e..329d3c8de 100644 --- a/docs/api/runtime-constants.md +++ b/docs/api/runtime-constants.md @@ -1,6 +1,6 @@ -# Runtime Storage +# Runtime Constant -There are **69** storages from **35** pallets. +There are **69** constants from **35** pallets. <ul> @@ -15,8 +15,7 @@ There are **69** storages from **35** pallets. Block & extrinsics weights: base values and limits. ```rust -value: { base_block: { ref_time: 453383000, proof_size: 0 }, max_block: { ref_time: 2000000000000, proof_size: 18446744073709551615 }, per_class: { normal: { base_extrinsic: { ref_time: 107074000, proof_size: 0 }, max_extrinsic: Some ({ ref_time: 1299892926000, proof_size: 11990383647911208550 }), max_total: Some ({ ref_time: 1500000000000, proof_size: 13835058055282163711 }), reserved: Some ({ ref_time: 0, proof_size: 0 }) }, operational: { base_extrinsic: { ref_time: 107074000, proof_size: 0 }, max_extrinsic: Some ({ ref_time: 1799892926000, proof_size: 16602069666338596454 }), max_total: Some ({ ref_time: 2000000000000, proof_size: 18446744073709551615 }), reserved: Some ({ ref_time: 500000000000, proof_size: 4611686018427387904 }) }, mandatory: { base_extrinsic: { ref_time: 107074000, proof_size: 0 }, max_extrinsic: None (), max_total: None (), reserved: None () } } } -type: frame_system::limits::BlockWeights +value: frame_system::limits::BlockWeights({ base_block: { ref_time: 453383000, proof_size: 0 }, max_block: { ref_time: 2000000000000, proof_size: 18446744073709551615 }, per_class: { normal: { base_extrinsic: { ref_time: 107074000, proof_size: 0 }, max_extrinsic: Some ({ ref_time: 1299892926000, proof_size: 11990383647911208550 }), max_total: Some ({ ref_time: 1500000000000, proof_size: 13835058055282163711 }), reserved: Some ({ ref_time: 0, proof_size: 0 }) }, operational: { base_extrinsic: { ref_time: 107074000, proof_size: 0 }, max_extrinsic: Some ({ ref_time: 1799892926000, proof_size: 16602069666338596454 }), max_total: Some ({ ref_time: 2000000000000, proof_size: 18446744073709551615 }), reserved: Some ({ ref_time: 500000000000, proof_size: 4611686018427387904 }) }, mandatory: { base_extrinsic: { ref_time: 107074000, proof_size: 0 }, max_extrinsic: None (), max_total: None (), reserved: None () } } }) ``` </details> @@ -30,8 +29,7 @@ type: frame_system::limits::BlockWeights The maximum length of a block (in bytes). ```rust -value: { max: { normal: 3932160, operational: 5242880, mandatory: 5242880 } } -type: frame_system::limits::BlockLength +value: frame_system::limits::BlockLength({ max: { normal: 3932160, operational: 5242880, mandatory: 5242880 } }) ``` </details> @@ -45,8 +43,7 @@ type: frame_system::limits::BlockLength Maximum number of block number to block hash mappings to keep (oldest pruned first). ```rust -value: 2400 -type: U32 +value: U32(2400) ``` </details> @@ -60,8 +57,7 @@ type: U32 The weight of runtime database operations the runtime can invoke. ```rust -value: { read: 21040000, write: 104032000 } -type: sp_weights::RuntimeDbWeight +value: sp_weights::RuntimeDbWeight({ read: 21040000, write: 104032000 }) ``` </details> @@ -75,8 +71,7 @@ type: sp_weights::RuntimeDbWeight Get the chain's in-code version. ```rust -value: { spec_name: "gdev", impl_name: "duniter-gdev", authoring_version: 1, spec_version: 800, impl_version: 1, apis: ((((104, 122, 212, 74, 211, 127, 3, 194), 1), ((203, 202, 37, 227, 159, 20, 35, 135), 2), ((223, 106, 203, 104, 153, 7, 96, 155), 5), ((55, 227, 151, 252, 124, 145, 245, 228), 2), ((64, 254, 58, 212, 1, 248, 149, 154), 6), ((210, 188, 152, 151, 238, 208, 143, 21), 3), ((247, 139, 39, 139, 229, 63, 69, 76), 2), ((171, 60, 5, 114, 41, 31, 235, 139), 1), ((237, 153, 197, 172, 178, 94, 237, 245), 3), ((188, 157, 137, 144, 79, 91, 146, 63), 1), ((55, 200, 187, 19, 80, 169, 162, 168), 4), ((251, 197, 119, 185, 215, 71, 239, 214), 1))), transaction_version: 1, state_version: 1 } -type: sp_version::RuntimeVersion +value: sp_version::RuntimeVersion({ spec_name: "gdev", impl_name: "duniter-gdev", authoring_version: 1, spec_version: 800, impl_version: 1, apis: ((((104, 122, 212, 74, 211, 127, 3, 194), 1), ((203, 202, 37, 227, 159, 20, 35, 135), 2), ((223, 106, 203, 104, 153, 7, 96, 155), 5), ((55, 227, 151, 252, 124, 145, 245, 228), 2), ((64, 254, 58, 212, 1, 248, 149, 154), 6), ((210, 188, 152, 151, 238, 208, 143, 21), 3), ((247, 139, 39, 139, 229, 63, 69, 76), 2), ((171, 60, 5, 114, 41, 31, 235, 139), 1), ((237, 153, 197, 172, 178, 94, 237, 245), 3), ((188, 157, 137, 144, 79, 91, 146, 63), 1), ((55, 200, 187, 19, 80, 169, 162, 168), 4), ((251, 197, 119, 185, 215, 71, 239, 214), 1))), transaction_version: 1, state_version: 1 }) ``` </details> @@ -94,8 +89,7 @@ type: sp_version::RuntimeVersion an identifier of the chain. ```rust -value: 42 -type: U16 +value: U16(42) ``` </details> @@ -121,8 +115,7 @@ type: U16 The maximum weight that may be scheduled per block for any dispatchables. ```rust -value: { ref_time: 1600000000000, proof_size: 14757395258967641292 } -type: sp_weights::weight_v2::Weight +value: sp_weights::weight_v2::Weight({ ref_time: 1600000000000, proof_size: 14757395258967641292 }) ``` </details> @@ -140,8 +133,7 @@ type: sp_weights::weight_v2::Weight higher limit under `runtime-benchmarks` feature. ```rust -value: 50 -type: U32 +value: U32(50) ``` </details> @@ -163,8 +155,7 @@ type: U32 the chain has started. Attempting to do so will brick block production. ```rust -value: 30 -type: U64 +value: U64(30) ``` </details> @@ -182,8 +173,7 @@ type: U64 the probability of a slot being empty). ```rust -value: 6000 -type: U64 +value: U64(6000) ``` </details> @@ -197,8 +187,7 @@ type: U64 Max number of authorities allowed ```rust -value: 32 -type: U32 +value: U32(32) ``` </details> @@ -212,8 +201,7 @@ type: U32 The maximum number of nominators for each validator. ```rust -value: 64 -type: U32 +value: U32(64) ``` </details> @@ -238,8 +226,7 @@ type: U32 period on default settings. ```rust -value: 3000 -type: U64 +value: U64(3000) ``` </details> @@ -272,8 +259,7 @@ type: U64 Bottom line: Do yourself a favour and make it at least one! ```rust -value: 100 -type: U64 +value: U64(100) ``` </details> @@ -290,8 +276,7 @@ type: U64 Use of locks is deprecated in favour of freezes. See `https://github.com/paritytech/substrate/pull/12951/` ```rust -value: 50 -type: U32 +value: U32(50) ``` </details> @@ -307,8 +292,7 @@ type: U32 Use of reserves is deprecated in favour of holds. See `https://github.com/paritytech/substrate/pull/12951/` ```rust -value: 5 -type: U32 +value: U32(5) ``` </details> @@ -322,8 +306,7 @@ type: U32 The maximum number of individual freeze locks that can exist on an account at any time. ```rust -value: 0 -type: U32 +value: U32(0) ``` </details> @@ -363,8 +346,7 @@ type: U32 transactions. ```rust -value: 5 -type: U8 +value: U8(5) ``` </details> @@ -390,8 +372,7 @@ type: U8 Account used to refund fees. ```rust -value: ((109, 111, 100, 108, 112, 121, 47, 116, 114, 115, 114, 121, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)) -type: sp_core::crypto::AccountId32 +value: sp_core::crypto::AccountId32(((109, 111, 100, 108, 112, 121, 47, 116, 114, 115, 114, 121, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0))) ``` </details> @@ -411,8 +392,7 @@ type: sp_core::crypto::AccountId32 Maximum number of active certifications per issuer. ```rust -value: 8 -type: U32 +value: U32(8) ``` </details> @@ -426,8 +406,7 @@ type: U32 Minimum number of certifications required to become a Smith. ```rust -value: 2 -type: U32 +value: U32(2) ``` </details> @@ -441,8 +420,7 @@ type: U32 Maximum duration of inactivity allowed before a Smith is removed. ```rust -value: 48 -type: U32 +value: U32(48) ``` </details> @@ -462,8 +440,7 @@ type: U32 Maximum number of authorities allowed. ```rust -value: 32 -type: U32 +value: U32(32) ``` </details> @@ -507,8 +484,7 @@ type: U32 Max Authorities in use ```rust -value: 32 -type: U32 +value: U32(32) ``` </details> @@ -522,8 +498,7 @@ type: U32 The maximum number of nominators for each validator. ```rust -value: 64 -type: U32 +value: U32(64) ``` </details> @@ -542,8 +517,7 @@ type: U32 can be zero. ```rust -value: 1000 -type: U64 +value: U64(1000) ``` </details> @@ -566,8 +540,7 @@ type: U64 multiple pallets send unsigned transactions. ```rust -value: 18446744073709551615 -type: U64 +value: U64(18446744073709551615) ``` </details> @@ -611,8 +584,7 @@ type: U64 The maximum weight of a dispatch call that can be proposed and executed. ```rust -value: { ref_time: 1000000000000, proof_size: 9223372036854775807 } -type: sp_weights::weight_v2::Weight +value: sp_weights::weight_v2::Weight({ ref_time: 1000000000000, proof_size: 9223372036854775807 }) ``` </details> @@ -632,8 +604,7 @@ type: sp_weights::weight_v2::Weight Maximum number of past UD revaluations to keep in storage. ```rust -value: 160 -type: U32 +value: U32(160) ``` </details> @@ -647,8 +618,7 @@ type: U32 Square of the money growth rate per UD reevaluation period. ```rust -value: (2381440) -type: sp_arithmetic::per_things::Perbill +value: sp_arithmetic::per_things::Perbill((2381440)) ``` </details> @@ -662,8 +632,7 @@ type: sp_arithmetic::per_things::Perbill Universal dividend creation period in milliseconds. ```rust -value: 60000 -type: U64 +value: U64(60000) ``` </details> @@ -677,8 +646,7 @@ type: U64 Universal dividend reevaluation period in milliseconds. ```rust -value: 1200000 -type: U64 +value: U64(1200000) ``` </details> @@ -698,8 +666,7 @@ type: U64 The block number from which the first certification can be issued. ```rust -value: 20 -type: U32 +value: U32(20) ``` </details> @@ -713,8 +680,7 @@ type: U32 The minimum number of certifications required for membership eligibility. ```rust -value: 2 -type: U32 +value: U32(2) ``` </details> @@ -728,8 +694,7 @@ type: U32 The minimum number of certifications required to create an identity. ```rust -value: 2 -type: U32 +value: U32(2) ``` </details> @@ -749,8 +714,7 @@ type: U32 The period during which the owner can confirm the new identity. ```rust -value: 40 -type: U32 +value: U32(40) ``` </details> @@ -764,8 +728,7 @@ type: U32 The period during which the identity has to be validated to become a member. ```rust -value: 876600 -type: U32 +value: U32(876600) ``` </details> @@ -779,8 +742,7 @@ type: U32 The period before which an identity that lost membership is automatically revoked. ```rust -value: 438300 -type: U32 +value: U32(438300) ``` </details> @@ -794,8 +756,7 @@ type: U32 The period after which a revoked identity is removed and the keys are freed. ```rust -value: 438300 -type: U32 +value: U32(438300) ``` </details> @@ -809,8 +770,7 @@ type: U32 The minimum duration between two owner key changes to prevent identity theft. ```rust -value: 100800 -type: U32 +value: U32(100800) ``` </details> @@ -825,8 +785,7 @@ type: U32 Should be greater than or equal to the certification period defined in the certification pallet. ```rust -value: 50 -type: U32 +value: U32(50) ``` </details> @@ -846,8 +805,7 @@ type: U32 Maximum lifespan of a single membership (in number of blocks). ```rust -value: 1000 -type: U32 +value: U32(1000) ``` </details> @@ -861,8 +819,7 @@ type: U32 Minimum delay to wait before renewing membership, i.e., asking for distance evaluation. ```rust -value: 1000 -type: U32 +value: U32(1000) ``` </details> @@ -882,8 +839,7 @@ type: U32 The minimum duration (in blocks) between two certifications issued by the same issuer. ```rust -value: 15 -type: U32 +value: U32(15) ``` </details> @@ -897,8 +853,7 @@ type: U32 The maximum number of active certifications that can be issued by a single issuer. ```rust -value: 10 -type: U32 +value: U32(10) ``` </details> @@ -913,8 +868,7 @@ type: U32 to be allowed to issue a certification. ```rust -value: 2 -type: U32 +value: U32(2) ``` </details> @@ -928,8 +882,7 @@ type: U32 The duration (in blocks) for which a certification remains valid. ```rust -value: 1000 -type: U32 +value: U32(1000) ``` </details> @@ -949,8 +902,7 @@ type: U32 The amount reserved during evaluation. ```rust -value: 1000 -type: U64 +value: U64(1000) ``` </details> @@ -965,8 +917,7 @@ type: U64 Since the evaluation uses 3 pools, the total evaluation time will be 3 * EvaluationPeriod. ```rust -value: 7 -type: U32 +value: U32(7) ``` </details> @@ -981,8 +932,7 @@ type: U32 This value is not used by the runtime but is needed by the client distance oracle. ```rust -value: 5 -type: U32 +value: U32(5) ``` </details> @@ -996,8 +946,7 @@ type: U32 The minimum ratio of accessible referees required. ```rust -value: (800000000) -type: sp_arithmetic::per_things::Perbill +value: sp_arithmetic::per_things::Perbill((800000000)) ``` </details> @@ -1026,8 +975,7 @@ type: sp_arithmetic::per_things::Perbill generates the proof instead. ```rust -value: 1024 -type: U32 +value: U32(1024) ``` </details> @@ -1052,8 +1000,7 @@ type: U32 `32 + sizeof(AccountId)` bytes. ```rust -value: 100 -type: U64 +value: U64(100) ``` </details> @@ -1069,8 +1016,7 @@ type: U64 This is held for adding 32 bytes more into a pre-existing storage value. ```rust -value: 32 -type: U64 +value: U64(32) ``` </details> @@ -1084,8 +1030,7 @@ type: U64 The maximum amount of signatories allowed in the multisig. ```rust -value: 10 -type: U32 +value: U32(10) ``` </details> @@ -1105,8 +1050,7 @@ type: U32 Maximum number of not yet filled requests. ```rust -value: 100 -type: U32 +value: U32(100) ``` </details> @@ -1120,8 +1064,7 @@ type: U32 The price of a request. ```rust -value: 2000 -type: U64 +value: U64(2000) ``` </details> @@ -1144,8 +1087,7 @@ type: U64 `sizeof(Balance)` bytes and whose key size is `sizeof(AccountId)` bytes. ```rust -value: 108 -type: U64 +value: U64(108) ``` </details> @@ -1163,8 +1105,7 @@ type: U64 into account `32 + proxy_type.encode().len()` bytes of data. ```rust -value: 33 -type: U64 +value: U64(33) ``` </details> @@ -1178,8 +1119,7 @@ type: U64 The maximum amount of proxies allowed for a single account. ```rust -value: 32 -type: U32 +value: U32(32) ``` </details> @@ -1193,8 +1133,7 @@ type: U32 The maximum amount of time-delayed announcements that are allowed to be pending. ```rust -value: 32 -type: U32 +value: U32(32) ``` </details> @@ -1211,8 +1150,7 @@ type: U32 bytes). ```rust -value: 108 -type: U64 +value: U64(108) ``` </details> @@ -1229,8 +1167,7 @@ type: U64 into a pre-existing storage value. ```rust -value: 66 -type: U64 +value: U64(66) ``` </details> @@ -1250,8 +1187,7 @@ type: U64 The limit on the number of batched calls. ```rust -value: 10922 -type: U32 +value: U32(10922) ``` </details> @@ -1271,8 +1207,7 @@ type: U32 Period between successive spends. ```rust -value: 14400 -type: U32 +value: U32(14400) ``` </details> @@ -1286,8 +1221,7 @@ type: U32 Percentage of spare funds (if any) that are burnt per spend period. ```rust -value: (0) -type: sp_arithmetic::per_things::Permill +value: sp_arithmetic::per_things::Permill((0)) ``` </details> @@ -1301,8 +1235,7 @@ type: sp_arithmetic::per_things::Permill The treasury's pallet id, used for deriving its sovereign account ID. ```rust -value: ((112, 121, 47, 116, 114, 115, 114, 121)) -type: frame_support::PalletId +value: frame_support::PalletId(((112, 121, 47, 116, 114, 115, 114, 121))) ``` </details> @@ -1318,8 +1251,7 @@ type: frame_support::PalletId NOTE: This parameter is also used within the Bounties Pallet extension if enabled. ```rust -value: 100 -type: U32 +value: U32(100) ``` </details> @@ -1333,8 +1265,7 @@ type: U32 The period during which an approved treasury spend has to be claimed. ```rust -value: 10 -type: U32 +value: U32(10) ``` </details> diff --git a/docs/api/runtime-storages.md b/docs/api/runtime-storages.md index a6022c323..c1bceb5cf 100644 --- a/docs/api/runtime-storages.md +++ b/docs/api/runtime-storages.md @@ -16,7 +16,7 @@ There are **136** storages from **35** pallets. ```rust key: sp_core::crypto::AccountId32 -value: frame_system::AccountInfo +value: frame_system::AccountInfo<U32, pallet_duniter_account::types::AccountData<U64, U32>> ``` </details> @@ -30,7 +30,7 @@ value: frame_system::AccountInfo Total extrinsics count for the current block. ```rust -value: U32 +value: Option<U32> ``` </details> @@ -58,7 +58,7 @@ value: Bool The current weight for the block. ```rust -value: frame_support::dispatch::PerDispatchClass +value: frame_support::dispatch::PerDispatchClass<sp_weights::weight_v2::Weight> ``` </details> @@ -72,7 +72,7 @@ value: frame_support::dispatch::PerDispatchClass Total length (in bytes) for all extrinsics put together, for the current block. ```rust -value: U32 +value: Option<U32> ``` </details> @@ -102,7 +102,7 @@ value: primitive_types::H256 ```rust key: U32 - +value: Vec<U8> ``` </details> @@ -163,7 +163,9 @@ value: sp_runtime::generic::digest::Digest Events have a large in-memory size. Box the events to not go out-of-memory just in case someone still reads them from within the runtime. - +```rust +value: Vec<frame_system::EventRecord<gdev_runtime::RuntimeEvent, primitive_types::H256>> +``` </details> </li> @@ -200,7 +202,7 @@ value: U32 ```rust key: primitive_types::H256 - +value: Vec<(U32, U32)> ``` </details> @@ -214,7 +216,7 @@ key: primitive_types::H256 Stores the `spec_version` and `spec_name` of when the last runtime upgrade happened. ```rust -value: frame_system::LastRuntimeUpgradeInfo +value: Option<frame_system::LastRuntimeUpgradeInfo> ``` </details> @@ -257,7 +259,7 @@ value: Bool The execution phase of the block. ```rust -value: frame_system::Phase +value: Option<frame_system::Phase> ``` </details> @@ -271,7 +273,7 @@ value: frame_system::Phase `Some` if a code upgrade has been authorized. ```rust -value: frame_system::CodeUpgradeAuthorization +value: Option<frame_system::CodeUpgradeAuthorization<>> ``` </details> @@ -297,7 +299,7 @@ value: frame_system::CodeUpgradeAuthorization ```rust -value: U32 +value: Option<U32> ``` </details> @@ -312,7 +314,7 @@ value: U32 ```rust key: U32 -value: bounded_collections::bounded_vec::BoundedVec +value: bounded_collections::bounded_vec::BoundedVec<Option<pallet_scheduler::Scheduled<[U8; 32], frame_support::traits::preimages::Bounded<gdev_runtime::RuntimeCall, sp_runtime::traits::BlakeTwo256>, U32, gdev_runtime::OriginCaller, sp_core::crypto::AccountId32>>, > ``` </details> @@ -326,7 +328,8 @@ value: bounded_collections::bounded_vec::BoundedVec Retry configurations for items to be executed, indexed by task address. ```rust -value: pallet_scheduler::RetryConfig +key: (U32, U32) +value: pallet_scheduler::RetryConfig<U32> ``` </details> @@ -342,7 +345,10 @@ value: pallet_scheduler::RetryConfig For v3 -> v4 the previously unbounded identities are Blake2-256 hashed to form the v4 identities. - +```rust +key: [U8; 32] +value: (U32, U32) +``` </details> </li> @@ -375,7 +381,7 @@ value: U64 Current epoch authorities. ```rust -value: bounded_collections::weak_bounded_vec::WeakBoundedVec +value: bounded_collections::weak_bounded_vec::WeakBoundedVec<(sp_consensus_babe::app::Public, U64), > ``` </details> @@ -426,7 +432,9 @@ value: sp_consensus_slots::Slot used where a number is needed that cannot have been chosen by an adversary, for purposes such as public-coin zero-knowledge proofs. - +```rust +value: [U8; 32] +``` </details> </li> @@ -439,7 +447,7 @@ value: sp_consensus_slots::Slot Pending epoch configuration change that will be applied when the next epoch is enacted. ```rust -value: sp_consensus_babe::digests::NextConfigDescriptor +value: Option<sp_consensus_babe::digests::NextConfigDescriptor> ``` </details> @@ -452,7 +460,9 @@ value: sp_consensus_babe::digests::NextConfigDescriptor </summary> Next epoch randomness. - +```rust +value: [U8; 32] +``` </details> </li> @@ -465,7 +475,7 @@ value: sp_consensus_babe::digests::NextConfigDescriptor Next epoch authorities. ```rust -value: bounded_collections::weak_bounded_vec::WeakBoundedVec +value: bounded_collections::weak_bounded_vec::WeakBoundedVec<(sp_consensus_babe::app::Public, U64), > ``` </details> @@ -502,7 +512,7 @@ value: U32 ```rust key: U32 -value: bounded_collections::bounded_vec::BoundedVec +value: bounded_collections::bounded_vec::BoundedVec<[U8; 32], > ``` </details> @@ -517,7 +527,7 @@ value: bounded_collections::bounded_vec::BoundedVec if per-block initialization has already been called for current block. ```rust -value: Option +value: Option<Option<sp_consensus_babe::digests::PreDigest>> ``` </details> @@ -534,7 +544,7 @@ value: Option It is set in `on_finalize`, before it will contain the value from the last block. ```rust -value: Option +value: Option<[U8; 32]> ``` </details> @@ -551,7 +561,9 @@ value: Option entropy was fixed (i.e. it was known to chain observers). Since epochs are defined in slots, which may be skipped, the block numbers may not line up with the slot numbers. - +```rust +value: (U32, U32) +``` </details> </li> @@ -583,7 +595,7 @@ value: U32 genesis. ```rust -value: sp_consensus_babe::BabeEpochConfiguration +value: Option<sp_consensus_babe::BabeEpochConfiguration> ``` </details> @@ -598,7 +610,7 @@ value: sp_consensus_babe::BabeEpochConfiguration (you can fallback to `EpochConfig` instead in that case). ```rust -value: sp_consensus_babe::BabeEpochConfiguration +value: Option<sp_consensus_babe::BabeEpochConfiguration> ``` </details> @@ -619,7 +631,7 @@ value: sp_consensus_babe::BabeEpochConfiguration active epoch index was during that session. ```rust -value: bounded_collections::bounded_vec::BoundedVec +value: bounded_collections::bounded_vec::BoundedVec<(U64, U32), > ``` </details> @@ -676,7 +688,7 @@ value: Bool ```rust -value: pallet_duniter_test_parameters::types::Parameters +value: pallet_duniter_test_parameters::types::Parameters<U32, U32, U64, U32> ``` </details> @@ -748,7 +760,7 @@ value: U64 ```rust key: sp_core::crypto::AccountId32 -value: pallet_balances::types::AccountData +value: pallet_balances::types::AccountData<U64> ``` </details> @@ -766,7 +778,7 @@ value: pallet_balances::types::AccountData ```rust key: sp_core::crypto::AccountId32 -value: bounded_collections::weak_bounded_vec::WeakBoundedVec +value: bounded_collections::weak_bounded_vec::WeakBoundedVec<pallet_balances::types::BalanceLock<U64>, > ``` </details> @@ -783,7 +795,7 @@ value: bounded_collections::weak_bounded_vec::WeakBoundedVec ```rust key: sp_core::crypto::AccountId32 -value: bounded_collections::bounded_vec::BoundedVec +value: bounded_collections::bounded_vec::BoundedVec<pallet_balances::types::ReserveData<[U8; 8], U64>, > ``` </details> @@ -798,7 +810,7 @@ value: bounded_collections::bounded_vec::BoundedVec ```rust key: sp_core::crypto::AccountId32 -value: bounded_collections::bounded_vec::BoundedVec +value: bounded_collections::bounded_vec::BoundedVec<frame_support::traits::tokens::misc::IdAmount<gdev_runtime::RuntimeHoldReason, U64>, > ``` </details> @@ -813,7 +825,7 @@ value: bounded_collections::bounded_vec::BoundedVec ```rust key: sp_core::crypto::AccountId32 -value: bounded_collections::bounded_vec::BoundedVec +value: bounded_collections::bounded_vec::BoundedVec<frame_support::traits::tokens::misc::IdAmount<(), U64>, > ``` </details> @@ -889,7 +901,7 @@ value: U64 ```rust key: U32 -value: pallet_quota::pallet::Quota +value: pallet_quota::pallet::Quota<U32, U64> ``` </details> @@ -903,7 +915,7 @@ value: pallet_quota::pallet::Quota The fees waiting to be refunded. ```rust -value: bounded_collections::bounded_vec::BoundedVec +value: bounded_collections::bounded_vec::BoundedVec<pallet_quota::pallet::Refund<sp_core::crypto::AccountId32, U32, U64>, > ``` </details> @@ -924,7 +936,7 @@ value: bounded_collections::bounded_vec::BoundedVec ```rust key: U32 -value: pallet_smith_members::types::SmithMeta +value: pallet_smith_members::types::SmithMeta<U32> ``` </details> @@ -939,7 +951,7 @@ value: pallet_smith_members::types::SmithMeta ```rust key: U32 - +value: Vec<U32> ``` </details> @@ -972,7 +984,9 @@ value: U32 </summary> The incoming authorities. - +```rust +value: Vec<U32> +``` </details> </li> @@ -984,7 +998,9 @@ value: U32 </summary> The online authorities. - +```rust +value: Vec<U32> +``` </details> </li> @@ -996,7 +1012,9 @@ value: U32 </summary> The outgoing authorities. - +```rust +value: Vec<U32> +``` </details> </li> @@ -1010,7 +1028,7 @@ value: U32 ```rust key: U32 -value: pallet_authority_members::types::MemberData +value: pallet_authority_members::types::MemberData<sp_core::crypto::AccountId32> ``` </details> @@ -1023,7 +1041,9 @@ value: pallet_authority_members::types::MemberData </summary> The blacklisted authorities. - +```rust +value: Vec<U32> +``` </details> </li> @@ -1042,7 +1062,7 @@ value: pallet_authority_members::types::MemberData Author of current block. ```rust -value: sp_core::crypto::AccountId32 +value: Option<sp_core::crypto::AccountId32> ``` </details> @@ -1063,7 +1083,7 @@ value: sp_core::crypto::AccountId32 ```rust key: primitive_types::H256 -value: sp_staking::offence::OffenceDetails +value: sp_staking::offence::OffenceDetails<sp_core::crypto::AccountId32, (sp_core::crypto::AccountId32, common_runtime::entities::ValidatorFullIdentification)> ``` </details> @@ -1076,7 +1096,10 @@ value: sp_staking::offence::OffenceDetails </summary> A vector of reports of the same kind that happened at the same time slot. - +```rust +key: ([U8; 16], Vec<U8>) +value: Vec<primitive_types::H256> +``` </details> </li> @@ -1096,7 +1119,7 @@ value: sp_staking::offence::OffenceDetails ```rust key: U32 - +value: (primitive_types::H256, U32) ``` </details> @@ -1109,7 +1132,9 @@ key: U32 </summary> The range of historical sessions we store. [first, last) - +```rust +value: Option<(U32, U32)> +``` </details> </li> @@ -1127,7 +1152,9 @@ key: U32 </summary> The current set of validators. - +```rust +value: Vec<sp_core::crypto::AccountId32> +``` </details> </li> @@ -1169,7 +1196,9 @@ value: Bool The queued keys for the next session. When the next session begins, these keys will be used to determine the validator's session keys. - +```rust +value: Vec<(sp_core::crypto::AccountId32, gdev_runtime::opaque::SessionKeys)> +``` </details> </li> @@ -1185,7 +1214,9 @@ value: Bool disabled using binary search. It gets cleared when `on_session_ending` returns a new set of identities. - +```rust +value: Vec<U32> +``` </details> </li> @@ -1213,6 +1244,7 @@ value: gdev_runtime::opaque::SessionKeys The owner of a key. The key is the `KeyTypeId` + the encoded key. ```rust +key: (sp_core::crypto::KeyTypeId, Vec<U8>) value: sp_core::crypto::AccountId32 ``` @@ -1233,7 +1265,7 @@ value: sp_core::crypto::AccountId32 State of the current authority set. ```rust -value: pallet_grandpa::StoredState +value: pallet_grandpa::StoredState<U32> ``` </details> @@ -1247,7 +1279,7 @@ value: pallet_grandpa::StoredState Pending change: (signaled at, scheduled change). ```rust -value: pallet_grandpa::StoredPendingChange +value: Option<pallet_grandpa::StoredPendingChange<U32, >> ``` </details> @@ -1261,7 +1293,7 @@ value: pallet_grandpa::StoredPendingChange next block number where we can force a change. ```rust -value: U32 +value: Option<U32> ``` </details> @@ -1274,7 +1306,9 @@ value: U32 </summary> `true` if we are currently stalled. - +```rust +value: Option<(U32, U32)> +``` </details> </li> @@ -1326,7 +1360,7 @@ value: U32 The current list of authorities. ```rust -value: bounded_collections::weak_bounded_vec::WeakBoundedVec +value: bounded_collections::weak_bounded_vec::WeakBoundedVec<(sp_consensus_grandpa::app::Public, U64), > ``` </details> @@ -1370,7 +1404,7 @@ value: U32 The current set of keys that may issue a heartbeat. ```rust -value: bounded_collections::weak_bounded_vec::WeakBoundedVec +value: bounded_collections::weak_bounded_vec::WeakBoundedVec<pallet_im_online::sr25519::app_sr25519::Public, > ``` </details> @@ -1384,6 +1418,7 @@ value: bounded_collections::weak_bounded_vec::WeakBoundedVec For each session index, we keep a mapping of `SessionIndex` and `AuthIndex`. ```rust +key: (U32, U32) value: Bool ``` @@ -1399,6 +1434,7 @@ value: Bool number of blocks authored by the given authority. ```rust +key: (U32, sp_core::crypto::AccountId32) value: U32 ``` @@ -1419,7 +1455,7 @@ value: U32 Keys of the current authority set. ```rust -value: bounded_collections::weak_bounded_vec::WeakBoundedVec +value: bounded_collections::weak_bounded_vec::WeakBoundedVec<sp_authority_discovery::app::Public, > ``` </details> @@ -1433,7 +1469,7 @@ value: bounded_collections::weak_bounded_vec::WeakBoundedVec Keys of the next authority set. ```rust -value: bounded_collections::weak_bounded_vec::WeakBoundedVec +value: bounded_collections::weak_bounded_vec::WeakBoundedVec<sp_authority_discovery::app::Public, > ``` </details> @@ -1453,7 +1489,7 @@ value: bounded_collections::weak_bounded_vec::WeakBoundedVec The `AccountId` of the sudo key. ```rust -value: sp_core::crypto::AccountId32 +value: Option<sp_core::crypto::AccountId32> ``` </details> @@ -1480,7 +1516,7 @@ value: sp_core::crypto::AccountId32 ```rust key: primitive_types::H256 -value: pallet_preimage::OldRequestStatus +value: pallet_preimage::OldRequestStatus<sp_core::crypto::AccountId32, U64> ``` </details> @@ -1495,7 +1531,7 @@ value: pallet_preimage::OldRequestStatus ```rust key: primitive_types::H256 -value: pallet_preimage::RequestStatus +value: pallet_preimage::RequestStatus<sp_core::crypto::AccountId32, ()> ``` </details> @@ -1509,7 +1545,8 @@ value: pallet_preimage::RequestStatus ```rust -value: bounded_collections::bounded_vec::BoundedVec +key: (primitive_types::H256, U32) +value: bounded_collections::bounded_vec::BoundedVec<U8, > ``` </details> @@ -1529,7 +1566,7 @@ value: bounded_collections::bounded_vec::BoundedVec The hashes of the active proposals. ```rust -value: bounded_collections::bounded_vec::BoundedVec +value: bounded_collections::bounded_vec::BoundedVec<primitive_types::H256, > ``` </details> @@ -1559,7 +1596,7 @@ value: gdev_runtime::RuntimeCall ```rust key: primitive_types::H256 -value: pallet_collective::Votes +value: pallet_collective::Votes<sp_core::crypto::AccountId32, U32> ``` </details> @@ -1586,7 +1623,9 @@ value: U32 </summary> The current members of the collective. This is stored sorted (just by value). - +```rust +value: Vec<sp_core::crypto::AccountId32> +``` </details> </li> @@ -1599,7 +1638,7 @@ value: U32 The prime member that helps determine the default vote behavior in case of abstentions. ```rust -value: sp_core::crypto::AccountId32 +value: Option<sp_core::crypto::AccountId32> ``` </details> @@ -1661,7 +1700,7 @@ value: U64 The next Universal Dividend re-evaluation. ```rust -value: U64 +value: Option<U64> ``` </details> @@ -1675,7 +1714,7 @@ value: U64 The next Universal Dividend creation. ```rust -value: U64 +value: Option<U64> ``` </details> @@ -1689,7 +1728,7 @@ value: U64 The past Universal Dividend re-evaluations. ```rust -value: bounded_collections::bounded_vec::BoundedVec +value: bounded_collections::bounded_vec::BoundedVec<(U16, U64), > ``` </details> @@ -1716,7 +1755,7 @@ value: bounded_collections::bounded_vec::BoundedVec ```rust key: U32 -value: pallet_identity::types::IdtyValue +value: pallet_identity::types::IdtyValue<U32, sp_core::crypto::AccountId32, common_runtime::entities::IdtyData> ``` </details> @@ -1789,7 +1828,7 @@ value: U32 ```rust key: U32 - +value: Vec<U32> ``` </details> @@ -1810,7 +1849,7 @@ key: U32 ```rust key: U32 -value: sp_membership::MembershipData +value: sp_membership::MembershipData<U32> ``` </details> @@ -1839,7 +1878,7 @@ value: U32 ```rust key: U32 - +value: Vec<U32> ``` </details> @@ -1860,7 +1899,7 @@ key: U32 ```rust key: U32 -value: pallet_certification::types::IdtyCertMeta +value: pallet_certification::types::IdtyCertMeta<U32> ``` </details> @@ -1875,7 +1914,7 @@ value: pallet_certification::types::IdtyCertMeta ```rust key: U32 - +value: Vec<(U32, U32)> ``` </details> @@ -1890,7 +1929,7 @@ key: U32 ```rust key: U32 - +value: Vec<(U32, U32)> ``` </details> @@ -1911,7 +1950,7 @@ key: U32 evaluator account. ```rust -value: pallet_distance::types::EvaluationPool +value: pallet_distance::types::EvaluationPool<sp_core::crypto::AccountId32, U32> ``` </details> @@ -1926,7 +1965,7 @@ value: pallet_distance::types::EvaluationPool evaluator account. ```rust -value: pallet_distance::types::EvaluationPool +value: pallet_distance::types::EvaluationPool<sp_core::crypto::AccountId32, U32> ``` </details> @@ -1941,7 +1980,7 @@ value: pallet_distance::types::EvaluationPool evaluator account. ```rust -value: pallet_distance::types::EvaluationPool +value: pallet_distance::types::EvaluationPool<sp_core::crypto::AccountId32, U32> ``` </details> @@ -2018,7 +2057,8 @@ value: U32 ```rust -value: pallet_atomic_swap::PendingSwap +key: (sp_core::crypto::AccountId32, [U8; 32]) +value: pallet_atomic_swap::PendingSwap<> ``` </details> @@ -2038,7 +2078,8 @@ value: pallet_atomic_swap::PendingSwap The set of open multisig operations. ```rust -value: pallet_multisig::Multisig +key: (sp_core::crypto::AccountId32, [U8; 32]) +value: pallet_multisig::Multisig<U32, U64, sp_core::crypto::AccountId32, > ``` </details> @@ -2085,7 +2126,9 @@ value: U64 </summary> The requests that will be fulfilled at the next block. - +```rust +value: Vec<pallet_provide_randomness::types::Request> +``` </details> </li> @@ -2099,7 +2142,7 @@ value: U64 ```rust key: U64 - +value: Vec<pallet_provide_randomness::types::Request> ``` </details> @@ -2114,7 +2157,7 @@ key: U64 ```rust key: U64 - +value: () ``` </details> @@ -2150,7 +2193,7 @@ value: U32 ```rust key: sp_core::crypto::AccountId32 - +value: (bounded_collections::bounded_vec::BoundedVec<pallet_proxy::ProxyDefinition<sp_core::crypto::AccountId32, gdev_runtime::ProxyType, U32>, >, U64) ``` </details> @@ -2165,7 +2208,7 @@ key: sp_core::crypto::AccountId32 ```rust key: sp_core::crypto::AccountId32 - +value: (bounded_collections::bounded_vec::BoundedVec<pallet_proxy::Announcement<sp_core::crypto::AccountId32, primitive_types::H256, U32>, >, U64) ``` </details> @@ -2206,7 +2249,7 @@ value: U32 ```rust key: U32 -value: pallet_treasury::Proposal +value: pallet_treasury::Proposal<sp_core::crypto::AccountId32, U64> ``` </details> @@ -2234,7 +2277,7 @@ value: U64 Proposal indices that have been approved but not yet awarded. ```rust -value: bounded_collections::bounded_vec::BoundedVec +value: bounded_collections::bounded_vec::BoundedVec<U32, > ``` </details> @@ -2263,7 +2306,7 @@ value: U32 ```rust key: U32 -value: pallet_treasury::SpendStatus +value: pallet_treasury::SpendStatus<(), U64, sp_core::crypto::AccountId32, U32, ()> ``` </details> diff --git a/xtask/res/templates/runtime-constants.md b/xtask/res/templates/runtime-constants.md index 6b62b16a2..2b0dd53fb 100644 --- a/xtask/res/templates/runtime-constants.md +++ b/xtask/res/templates/runtime-constants.md @@ -1,6 +1,6 @@ -# Runtime Storage +# Runtime Constant -There are **{{ constant_counter }}** storages from **{{ pallets | length }}** pallets. +There are **{{ constant_counter }}** constants from **{{ pallets | length }}** pallets. <ul> {% for pallet in pallets %} @@ -15,8 +15,7 @@ There are **{{ constant_counter }}** storages from **{{ pallets | length }}** pa {{ constant.documentation }} ```rust -value: {{ constant.value }} -type: {{ constant.type_value }} +value: {{ constant.type_value }}({{ constant.value }}) ``` </details> diff --git a/xtask/src/gen_doc.rs b/xtask/src/gen_doc.rs index 5b56bf95a..b28d00692 100644 --- a/xtask/src/gen_doc.rs +++ b/xtask/src/gen_doc.rs @@ -17,8 +17,8 @@ use anyhow::{bail, Context, Result}; use codec::Decode; use core::hash::Hash; -use frame_metadata::v15::StorageEntryType; -use scale_info::form::PortableForm; +use frame_metadata::v15::{StorageEntryModifier, StorageEntryType}; +use scale_info::{form::PortableForm, PortableRegistry, Type, TypeDef}; use serde::Serialize; use std::{ collections::HashMap, @@ -440,6 +440,70 @@ fn get_max_weight_from_metadata_v15( } } +fn format_type(ty: &Type<PortableForm>, types: &PortableRegistry) -> String { + let path = ty.path.to_string(); + + match &ty.type_def { + TypeDef::Composite(_) => { + let generics = format_generics(&ty.type_params, types); + format!("{}{}", path, generics) + } + TypeDef::Variant(_) => { + let generics = format_generics(&ty.type_params, types); + format!("{}{}", path, generics) + } + TypeDef::Sequence(seq) => { + let element_type = resolve_type(seq.type_param.id, types); + format!("Vec<{}>", element_type) + } + TypeDef::Array(arr) => { + let element_type = resolve_type(arr.type_param.id, types); + format!("[{}; {}]", element_type, arr.len) + } + TypeDef::Tuple(tuple) => { + let elements: Vec<String> = tuple + .fields + .iter() + .map(|f| resolve_type(f.id, types)) + .collect(); + format!("({})", elements.join(", ")) + } + TypeDef::Primitive(primitive) => { + format!("{:?}", primitive) + } + TypeDef::Compact(compact) => { + let inner_type = resolve_type(compact.type_param.id, types); + format!("Compact<{}>", inner_type) + } + TypeDef::BitSequence(_) => "".to_string(), + } +} + +fn resolve_type(type_id: u32, types: &PortableRegistry) -> String { + types + .resolve(type_id) + .map(|t| format_type(t, types)) + .unwrap_or_else(|| "Unknown".to_string()) +} + +fn format_generics( + params: &[scale_info::TypeParameter<PortableForm>], + types: &PortableRegistry, +) -> String { + if params.is_empty() { + "".to_string() + } else { + let generics: Vec<String> = params + .iter() + .map(|p| { + p.ty.map(|ty| resolve_type(ty.id, types)) + .unwrap_or_default() + }) + .collect(); + format!("<{}>", generics.join(", ")) + } +} + fn get_from_metadata_v15( metadata_v15: frame_metadata::v15::RuntimeMetadataV15, ) -> Result<RuntimePallets> { @@ -492,18 +556,7 @@ fn get_from_metadata_v15( metadata_v15 .types .resolve(type_id) - .map(|resolved| { - let path = resolved.path.to_string(); - if !path.is_empty() { - path - } else if let scale_info::TypeDef::Primitive(v) = - &resolved.type_def - { - format!("{:?}", v) - } else { - String::default() - } - }) + .map(|resolved| format_type(resolved, &metadata_v15.types)) .unwrap_or_default() }; match &variant.ty { @@ -517,7 +570,13 @@ fn get_from_metadata_v15( documentation: variant.docs.join("\n"), name: variant.name.clone(), type_key: String::default(), - type_value: resolve_type(v.id), + type_value: if let StorageEntryModifier::Optional = + &variant.modifier + { + format!("Option<{}>", resolve_type(v.id)) + } else { + resolve_type(v.id) + }, }, } }) @@ -533,16 +592,7 @@ fn get_from_metadata_v15( metadata_v15 .types .resolve(type_id) - .map(|resolved| { - let path = resolved.path.to_string(); - if !path.is_empty() { - path - } else if let scale_info::TypeDef::Primitive(v) = &resolved.type_def { - format!("{:?}", v) - } else { - String::default() - } - }) + .map(|resolved| format_type(resolved, &metadata_v15.types)) .unwrap_or_default() }; -- GitLab From 7ccedac8c8d577698d03fcb3738374a22ac1faeb Mon Sep 17 00:00:00 2001 From: bgallois <benjamin@gallois.cc> Date: Tue, 4 Feb 2025 15:43:32 +0100 Subject: [PATCH 5/7] refactore errors --- xtask/src/gen_doc.rs | 153 +++++++++++++++++++++---------------------- 1 file changed, 75 insertions(+), 78 deletions(-) diff --git a/xtask/src/gen_doc.rs b/xtask/src/gen_doc.rs index b28d00692..eb5dc2d81 100644 --- a/xtask/src/gen_doc.rs +++ b/xtask/src/gen_doc.rs @@ -440,67 +440,96 @@ fn get_max_weight_from_metadata_v15( } } -fn format_type(ty: &Type<PortableForm>, types: &PortableRegistry) -> String { +fn format_type(ty: &Type<PortableForm>, types: &PortableRegistry) -> Result<String> { let path = ty.path.to_string(); match &ty.type_def { TypeDef::Composite(_) => { - let generics = format_generics(&ty.type_params, types); - format!("{}{}", path, generics) + let generics = format_generics(&ty.type_params, types)?; + Ok(format!("{}{}", path, generics)) } TypeDef::Variant(_) => { - let generics = format_generics(&ty.type_params, types); - format!("{}{}", path, generics) + let generics = format_generics(&ty.type_params, types)?; + Ok(format!("{}{}", path, generics)) } TypeDef::Sequence(seq) => { - let element_type = resolve_type(seq.type_param.id, types); - format!("Vec<{}>", element_type) + let element_type = resolve_type(seq.type_param.id, types)?; + Ok(format!("Vec<{}>", element_type)) } TypeDef::Array(arr) => { - let element_type = resolve_type(arr.type_param.id, types); - format!("[{}; {}]", element_type, arr.len) + let element_type = resolve_type(arr.type_param.id, types)?; + Ok(format!("[{}; {}]", element_type, arr.len)) } TypeDef::Tuple(tuple) => { - let elements: Vec<String> = tuple + let elements = tuple .fields .iter() .map(|f| resolve_type(f.id, types)) - .collect(); - format!("({})", elements.join(", ")) - } - TypeDef::Primitive(primitive) => { - format!("{:?}", primitive) + .collect::<Result<Vec<String>>>()?; + Ok(format!("({})", elements.join(", "))) } + TypeDef::Primitive(primitive) => Ok(format!("{:?}", primitive)), TypeDef::Compact(compact) => { - let inner_type = resolve_type(compact.type_param.id, types); - format!("Compact<{}>", inner_type) + let inner_type = resolve_type(compact.type_param.id, types)?; + Ok(format!("Compact<{}>", inner_type)) } - TypeDef::BitSequence(_) => "".to_string(), + TypeDef::BitSequence(_) => Ok(String::default()), } } -fn resolve_type(type_id: u32, types: &PortableRegistry) -> String { +fn resolve_type(type_id: u32, types: &PortableRegistry) -> Result<String> { types .resolve(type_id) .map(|t| format_type(t, types)) - .unwrap_or_else(|| "Unknown".to_string()) + .unwrap_or_else(|| bail!("Invalid metadata")) } fn format_generics( params: &[scale_info::TypeParameter<PortableForm>], types: &PortableRegistry, -) -> String { +) -> Result<String> { if params.is_empty() { - "".to_string() + Ok(String::default()) } else { - let generics: Vec<String> = params + let generics = params .iter() .map(|p| { p.ty.map(|ty| resolve_type(ty.id, types)) - .unwrap_or_default() + .unwrap_or_else(|| Ok(String::default())) }) - .collect(); - format!("<{}>", generics.join(", ")) + .collect::<Result<Vec<String>>>()?; + Ok(format!("<{}>", generics.join(", "))) + } +} +fn parse_storage_entry( + variant: &frame_metadata::v15::StorageEntryMetadata<scale_info::form::PortableForm>, + types: &PortableRegistry, +) -> Result<Storage> { + match &variant.ty { + StorageEntryType::Map { key, value, .. } => { + let type_key = resolve_type(key.id, types)?; + let type_value = resolve_type(value.id, types)?; + Ok(Storage { + documentation: variant.docs.join("\n"), + name: variant.name.clone(), + type_key, + type_value, + }) + } + StorageEntryType::Plain(v) => { + let type_value = resolve_type(v.id, types)?; + let type_value = if let StorageEntryModifier::Optional = &variant.modifier { + format!("Option<{}>", type_value) + } else { + type_value + }; + Ok(Storage { + documentation: variant.docs.join("\n"), + name: variant.name.clone(), + type_key: String::default(), + type_value, + }) + } } } @@ -545,71 +574,39 @@ fn get_from_metadata_v15( None }; - let storages: Vec<Storage> = pallet + let storages = pallet .storage .map(|storage| { storage .entries .iter() - .map(|variant| { - let resolve_type = |type_id: u32| -> String { - metadata_v15 - .types - .resolve(type_id) - .map(|resolved| format_type(resolved, &metadata_v15.types)) - .unwrap_or_default() - }; - match &variant.ty { - StorageEntryType::Map { key, value, .. } => Storage { - documentation: variant.docs.join("\n"), - name: variant.name.clone(), - type_key: resolve_type(key.id), - type_value: resolve_type(value.id), - }, - StorageEntryType::Plain(v) => Storage { - documentation: variant.docs.join("\n"), - name: variant.name.clone(), - type_key: String::default(), - type_value: if let StorageEntryModifier::Optional = - &variant.modifier - { - format!("Option<{}>", resolve_type(v.id)) - } else { - resolve_type(v.id) - }, - }, - } - }) - .collect() + .map(|v| parse_storage_entry(v, &metadata_v15.types)) + .collect::<Result<Vec<Storage>>>() }) - .unwrap_or_default(); + .unwrap_or_else(|| { + println!("{}: {} (0 storage)", pallet.index, pallet.name); + Ok(Vec::default()) + })?; - let constants: Vec<Constant> = pallet + let constants = pallet .constants .iter() .map(|i| { - let resolve_type = |type_id: u32| -> String { - metadata_v15 - .types - .resolve(type_id) - .map(|resolved| format_type(resolved, &metadata_v15.types)) - .unwrap_or_default() - }; - - let decode_value = |value: &Vec<u8>, type_id: u32| -> String { - scale_value::scale::decode_as_type(&mut &**value, &type_id, &metadata_v15.types) - .map(|v| v.to_string()) - .unwrap_or_default() - }; - - Constant { + let type_value = resolve_type(i.ty.id, &metadata_v15.types)?; + let value = scale_value::scale::decode_as_type( + &mut &*i.value, + &i.ty.id, + &metadata_v15.types, + ) + .map_err(|e| anyhow::anyhow!("{}", e))?; + Ok(Constant { documentation: i.docs.join("\n"), name: i.name.clone(), - value: decode_value(&i.value, i.ty.id), - type_value: resolve_type(i.ty.id), - } + value: value.to_string(), + type_value, + }) }) - .collect(); + .collect::<Result<Vec<Constant>>>()?; let pallet = Pallet::new( pallet.index, -- GitLab From 9f7ae2ee709ffad1f05176871a550171d7023735 Mon Sep 17 00:00:00 2001 From: bgallois <benjamin@gallois.cc> Date: Tue, 4 Feb 2025 16:34:12 +0100 Subject: [PATCH 6/7] add documentation --- xtask/src/gen_doc.rs | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/xtask/src/gen_doc.rs b/xtask/src/gen_doc.rs index eb5dc2d81..a2eb94a90 100644 --- a/xtask/src/gen_doc.rs +++ b/xtask/src/gen_doc.rs @@ -440,6 +440,24 @@ fn get_max_weight_from_metadata_v15( } } +/// Converts a `Type<PortableForm>` into a human-readable string representation. +/// +/// This function is a core part of the type resolution pipeline, working together with: +/// - `resolve_type()` to obtain type definitions. +/// - `format_generics()` to correctly format generic parameters. +/// +/// It processes a `Type<PortableForm>` from the metadata registry and outputs a Rust-like string representation, +/// handling all supported type definitions (composite types, sequences, arrays, tuples, primitives, etc.). +/// +/// # Returns +/// - `Ok(String)`: A formatted type string (e.g., `"Vec<u32>"`, `"(i32, bool)"`). +/// - `Err(anyhow::Error)`: If metadata are incorrect. +/// +/// # How It Works With Other Functions: +/// - Calls `format_generics()` to handle generic type parameters. +/// - Calls `resolve_type()` when resolving inner types inside sequences, arrays, and tuples. +/// - Used by `resolve_type()` as a formatting step after retrieving a type. +/// fn format_type(ty: &Type<PortableForm>, types: &PortableRegistry) -> Result<String> { let path = ty.path.to_string(); @@ -477,6 +495,16 @@ fn format_type(ty: &Type<PortableForm>, types: &PortableRegistry) -> Result<Stri } } +/// Resolves a type ID to a formatted string representation. +/// +/// This function serves as a bridge between raw type IDs and fully formatted types. +/// It works closely with `format_type()`, ensuring that once a type is found, it is properly formatted. +/// +/// # How It Works With Other Functions: +/// - Retrieves a type from the registry using `types.resolve(type_id)`. +/// - If successful, calls `format_type()` to get a human-readable format. +/// - Used internally by `format_type()` when resolving type dependencies. +/// fn resolve_type(type_id: u32, types: &PortableRegistry) -> Result<String> { types .resolve(type_id) @@ -484,6 +512,16 @@ fn resolve_type(type_id: u32, types: &PortableRegistry) -> Result<String> { .unwrap_or_else(|| bail!("Invalid metadata")) } +/// Formats generic type parameters into a Rust-like string representation. +/// +/// This function helps `format_type()` handle generic types, ensuring that type parameters +/// are formatted correctly when they exist. If a type has generic parameters, they are enclosed +/// in angle brackets (e.g., `<T, U>`). +/// +/// # How It Works With Other Functions: +/// - Called inside `format_type()` to process generic type parameters. +/// - Uses `resolve_type()` to retrieve and format each generic type. +/// fn format_generics( params: &[scale_info::TypeParameter<PortableForm>], types: &PortableRegistry, @@ -501,6 +539,7 @@ fn format_generics( Ok(format!("<{}>", generics.join(", "))) } } + fn parse_storage_entry( variant: &frame_metadata::v15::StorageEntryMetadata<scale_info::form::PortableForm>, types: &PortableRegistry, -- GitLab From fd9b49c5920e3d2100559b8b7f3015948d72132c Mon Sep 17 00:00:00 2001 From: Hugo Trentesaux <hugo@trentesaux.fr> Date: Tue, 4 Feb 2025 22:03:21 +0100 Subject: [PATCH 7/7] cargo xtask gen-doc --- docs/api/runtime-calls.md | 154 ++++++++++++++++++++++------------ docs/api/runtime-constants.md | 9 +- docs/api/runtime-errors.md | 9 +- docs/api/runtime-errors.po | 2 + docs/api/runtime-events.md | 44 +++++++++- docs/api/runtime-storages.md | 43 +++++++++- 6 files changed, 198 insertions(+), 63 deletions(-) diff --git a/docs/api/runtime-calls.md b/docs/api/runtime-calls.md index 5adde95a8..38dcb37cc 100644 --- a/docs/api/runtime-calls.md +++ b/docs/api/runtime-calls.md @@ -12,7 +12,7 @@ Calls are categorized according to the dispatch origin they require: We only document user calls below. -There are **63** user calls from **17** pallets. +There are **65** user calls from **17** pallets. ## Account - 1 @@ -20,7 +20,7 @@ There are **63** user calls from **17** pallets. <details><summary><code>unlink_identity()</code></summary> -Taking 0.0109 % of a block. +Taking 0.0106 % of a block. ```rust ``` @@ -36,7 +36,7 @@ Unlink the identity associated with the account. <details><summary><code>transfer_allow_death(dest, value)</code></summary> -Taking 0.0194 % of a block. +Taking 0.0186 % of a block. ```rust dest: AccountIdLookupOf<T> @@ -58,7 +58,7 @@ The dispatch origin for this call must be `Signed` by the transactor. <details><summary><code>transfer_keep_alive(dest, value)</code></summary> -Taking 0.0122 % of a block. +Taking 0.0119 % of a block. ```rust dest: AccountIdLookupOf<T> @@ -79,7 +79,7 @@ kill the origin account. <details><summary><code>transfer_all(dest, keep_alive)</code></summary> -Taking 0.0126 % of a block. +Taking 0.0122 % of a block. ```rust dest: AccountIdLookupOf<T> @@ -111,7 +111,7 @@ The dispatch origin of this call must be Signed. <details><summary><code>create_oneshot_account(dest, value)</code></summary> -Taking 0.0117 % of a block. +Taking 0.0115 % of a block. ```rust dest: <T::Lookup as StaticLookup>::Source @@ -132,7 +132,7 @@ Origin account is kept alive. <details><summary><code>consume_oneshot_account(block_height, dest)</code></summary> -Taking 0.0195 % of a block. +Taking 0.0182 % of a block. ```rust block_height: BlockNumberFor<T> @@ -152,7 +152,7 @@ Consume a oneshot account and transfer its balance to an account <details><summary><code>consume_oneshot_account_with_remaining(block_height, dest, remaining_to, balance)</code></summary> -Taking 0.0265 % of a block. +Taking 0.0246 % of a block. ```rust block_height: BlockNumberFor<T> @@ -181,7 +181,7 @@ and the remaining amount to another account. <details><summary><code>invite_smith(receiver)</code></summary> -Taking 0.024 % of a block. +Taking 0.0214 % of a block. ```rust receiver: T::IdtyIndex @@ -196,7 +196,7 @@ Invite a member of the Web of Trust to attempt becoming a Smith. <details><summary><code>accept_invitation()</code></summary> -Taking 0.0126 % of a block. +Taking 0.0119 % of a block. ```rust ``` @@ -210,7 +210,7 @@ Accept an invitation to become a Smith (must have been invited first). <details><summary><code>certify_smith(receiver)</code></summary> -Taking 0.0279 % of a block. +Taking 0.0255 % of a block. ```rust receiver: T::IdtyIndex @@ -227,7 +227,7 @@ Certify an invited Smith, which can lead the certified to become a Smith. <details><summary><code>go_offline()</code></summary> -Taking 0.0172 % of a block. +Taking 0.0152 % of a block. ```rust ``` @@ -241,7 +241,7 @@ Request to leave the set of validators two sessions later. <details><summary><code>go_online()</code></summary> -Taking 0.0199 % of a block. +Taking 0.0172 % of a block. ```rust ``` @@ -255,7 +255,7 @@ Request to join the set of validators two sessions later. <details><summary><code>set_session_keys(keys)</code></summary> -Taking 0.0256 % of a block. +Taking 0.0225 % of a block. ```rust keys: T::Keys @@ -272,7 +272,7 @@ Declare new session keys to replace current ones. <details><summary><code>note_preimage(bytes)</code></summary> -Taking 0.2845 % of a block. +Taking 0.2846 % of a block. ```rust bytes: Vec<u8> @@ -290,7 +290,7 @@ the preimage. Otherwise, a deposit is taken proportional to the size of the prei <details><summary><code>unnote_preimage(hash)</code></summary> -Taking 0.0181 % of a block. +Taking 0.0171 % of a block. ```rust hash: T::Hash @@ -310,7 +310,7 @@ If `len` is provided, then it will be a much cheaper operation. <details><summary><code>request_preimage(hash)</code></summary> -Taking 0.0128 % of a block. +Taking 0.0121 % of a block. ```rust hash: T::Hash @@ -328,7 +328,7 @@ a user may have paid, and take the control of the preimage out of their hands. <details><summary><code>unrequest_preimage(hash)</code></summary> -Taking 0.018 % of a block. +Taking 0.0171 % of a block. ```rust hash: T::Hash @@ -345,7 +345,7 @@ NOTE: THIS MUST NOT BE CALLED ON `hash` MORE TIMES THAN `request_preimage`. <details><summary><code>ensure_updated(hashes)</code></summary> -Taking 18.8992 % of a block. +Taking 17.5344 % of a block. ```rust hashes: Vec<T::Hash> @@ -364,7 +364,7 @@ The caller pays no fee if at least 90% of pre-images were successfully updated. <details><summary><code>execute(proposal, length_bound)</code></summary> -Taking 0.0061 % of a block. +Taking 0.006 % of a block. ```rust proposal: Box<<T as Config<I>>::Proposal> @@ -418,7 +418,7 @@ or put up for voting. <details><summary><code>vote(proposal, index, approve)</code></summary> -Taking 0.0128 % of a block. +Taking 0.0121 % of a block. ```rust proposal: T::Hash @@ -480,13 +480,57 @@ proposal. - `P1` is the complexity of `proposal` preimage. - `P2` is proposal-count (code-bounded) +### kill - 7 + +<details><summary><code>kill(proposal_hash)</code></summary> + +Taking 0.0229 % of a block. + +```rust +proposal_hash: T::Hash +``` +</details> + + + +Disapprove the proposal and burn the cost held for storing this proposal. + +Parameters: +- `origin`: must be the `KillOrigin`. +- `proposal_hash`: The hash of the proposal that should be killed. + +Emits `Killed` and `ProposalCostBurned` if any cost was held for a given proposal. + +### release_proposal_cost - 8 + +<details><summary><code>release_proposal_cost(proposal_hash)</code></summary> + +Taking 0.0066 % of a block. + +```rust +proposal_hash: T::Hash +``` +</details> + + + +Release the cost held for storing a proposal once the given proposal is completed. + +If there is no associated cost for the given proposal, this call will have no effect. + +Parameters: +- `origin`: must be `Signed` or `Root`. +- `proposal_hash`: The hash of the proposal. + +Emits `ProposalCostReleased` if any cost held for a given proposal. + ## UniversalDividend - 30 ### claim_uds - 0 <details><summary><code>claim_uds()</code></summary> -Taking 0.0219 % of a block. +Taking 0.02 % of a block. ```rust ``` @@ -500,7 +544,7 @@ Claim Universal Dividends. <details><summary><code>transfer_ud(dest, value)</code></summary> -Taking 0.0207 % of a block. +Taking 0.0194 % of a block. ```rust dest: <T::Lookup as StaticLookup>::Source @@ -516,7 +560,7 @@ Transfer some liquid free balance to another account, in milliUD. <details><summary><code>transfer_ud_keep_alive(dest, value)</code></summary> -Taking 0.0134 % of a block. +Taking 0.0129 % of a block. ```rust dest: <T::Lookup as StaticLookup>::Source @@ -534,7 +578,7 @@ Transfer some liquid free balance to another account in milliUD and keep the acc <details><summary><code>create_identity(owner_key)</code></summary> -Taking 0.0843 % of a block. +Taking 0.0776 % of a block. ```rust owner_key: T::AccountId @@ -553,7 +597,7 @@ The origin must be allowed to create an identity. <details><summary><code>confirm_identity(idty_name)</code></summary> -Taking 0.0322 % of a block. +Taking 0.0298 % of a block. ```rust idty_name: IdtyName @@ -572,7 +616,7 @@ The identity must have been created using `create_identity` before it can be con <details><summary><code>change_owner_key(new_key, new_key_sig)</code></summary> -Taking 0.0421 % of a block. +Taking 0.0388 % of a block. ```rust new_key: T::AccountId @@ -594,7 +638,7 @@ The origin should be the old identity owner key. <details><summary><code>revoke_identity(idty_index, revocation_key, revocation_sig)</code></summary> -Taking 0.0392 % of a block. +Taking 0.0365 % of a block. ```rust idty_index: T::IdtyIndex @@ -618,7 +662,7 @@ Any signed origin can execute this call. <details><summary><code>revoke_identity_legacy(revocation_document)</code></summary> -Taking 0.0392 % of a block. +Taking 0.04 % of a block. ```rust revocation_document: Vec<u8> @@ -637,7 +681,7 @@ Any signed origin can execute this call. <details><summary><code>link_account(account_id, payload_sig)</code></summary> -Taking 0.0155 % of a block. +Taking 0.0144 % of a block. ```rust account_id: T::AccountId @@ -662,7 +706,7 @@ identity to sign the operation. <details><summary><code>add_cert(receiver)</code></summary> -Taking 0.0357 % of a block. +Taking 0.0324 % of a block. ```rust receiver: T::IdtyIndex @@ -677,7 +721,7 @@ Add a new certification. <details><summary><code>renew_cert(receiver)</code></summary> -Taking 0.0295 % of a block. +Taking 0.0266 % of a block. ```rust receiver: T::IdtyIndex @@ -694,7 +738,7 @@ Renew an existing certification. <details><summary><code>request_distance_evaluation()</code></summary> -Taking 0.0393 % of a block. +Taking 0.0351 % of a block. ```rust ``` @@ -712,7 +756,7 @@ evaluation will result in slashing for the caller. <details><summary><code>request_distance_evaluation_for(target)</code></summary> -Taking 0.0404 % of a block. +Taking 0.036 % of a block. ```rust target: T::IdtyIndex @@ -806,7 +850,7 @@ The dispatch origin for this call must be _Signed_. <details><summary><code>as_multi_threshold_1(other_signatories, call)</code></summary> -Taking 0.0048 % of a block. +Taking 0.0051 % of a block. ```rust other_signatories: Vec<T::AccountId> @@ -938,7 +982,7 @@ NOTE: If this is the final approval, you will want to use `as_multi` instead. <details><summary><code>cancel_as_multi(threshold, other_signatories, timepoint, call_hash)</code></summary> -Taking 0.0121 % of a block. +Taking 0.0117 % of a block. ```rust threshold: u16 @@ -978,7 +1022,7 @@ transaction for this dispatch. <details><summary><code>request(randomness_type, salt)</code></summary> -Taking 0.0401 % of a block. +Taking 0.0367 % of a block. ```rust randomness_type: RandomnessType @@ -996,7 +1040,7 @@ Request randomness. <details><summary><code>proxy(real, force_proxy_type, call)</code></summary> -Taking 0.0062 % of a block. +Taking 0.0061 % of a block. ```rust real: AccountIdLookupOf<T> @@ -1021,7 +1065,7 @@ Parameters: <details><summary><code>add_proxy(delegate, proxy_type, delay)</code></summary> -Taking 0.0118 % of a block. +Taking 0.0114 % of a block. ```rust delegate: AccountIdLookupOf<T> @@ -1046,7 +1090,7 @@ zero. <details><summary><code>remove_proxy(delegate, proxy_type, delay)</code></summary> -Taking 0.0118 % of a block. +Taking 0.0114 % of a block. ```rust delegate: AccountIdLookupOf<T> @@ -1069,7 +1113,7 @@ Parameters: <details><summary><code>remove_proxies()</code></summary> -Taking 0.0117 % of a block. +Taking 0.0113 % of a block. ```rust ``` @@ -1088,7 +1132,7 @@ the unreserved fees will be inaccessible. **All access to this account will be l <details><summary><code>create_pure(proxy_type, delay, index)</code></summary> -Taking 0.0118 % of a block. +Taking 0.0114 % of a block. ```rust proxy_type: T::ProxyType @@ -1122,7 +1166,7 @@ Fails if there are insufficient funds to pay for deposit. <details><summary><code>kill_pure(spawner, proxy_type, index, height, ext_index)</code></summary> -Taking 0.0117 % of a block. +Taking 0.0114 % of a block. ```rust spawner: AccountIdLookupOf<T> @@ -1156,7 +1200,7 @@ account whose `pure` call has corresponding parameters. <details><summary><code>announce(real, call_hash)</code></summary> -Taking 0.0197 % of a block. +Taking 0.0185 % of a block. ```rust real: AccountIdLookupOf<T> @@ -1186,7 +1230,7 @@ Parameters: <details><summary><code>remove_announcement(real, call_hash)</code></summary> -Taking 0.0182 % of a block. +Taking 0.0173 % of a block. ```rust real: AccountIdLookupOf<T> @@ -1211,7 +1255,7 @@ Parameters: <details><summary><code>reject_announcement(delegate, call_hash)</code></summary> -Taking 0.0182 % of a block. +Taking 0.0173 % of a block. ```rust delegate: AccountIdLookupOf<T> @@ -1236,7 +1280,7 @@ Parameters: <details><summary><code>proxy_announced(delegate, real, force_proxy_type, call)</code></summary> -Taking 0.0198 % of a block. +Taking 0.0187 % of a block. ```rust delegate: AccountIdLookupOf<T> @@ -1266,7 +1310,7 @@ Parameters: <details><summary><code>batch(calls)</code></summary> -Taking 0.1076 % of a block. +Taking 0.1152 % of a block. ```rust calls: Vec<<T as Config>::RuntimeCall> @@ -1298,7 +1342,7 @@ event is deposited. <details><summary><code>as_derivative(index, call)</code></summary> -Taking 0.0046 % of a block. +Taking 0.0048 % of a block. ```rust index: u16 @@ -1326,7 +1370,7 @@ The dispatch origin for this call must be _Signed_. <details><summary><code>batch_all(calls)</code></summary> -Taking 0.1148 % of a block. +Taking 0.123 % of a block. ```rust calls: Vec<<T as Config>::RuntimeCall> @@ -1353,7 +1397,7 @@ includes bypassing `frame_system::Config::BaseCallFilter`). <details><summary><code>force_batch(calls)</code></summary> -Taking 0.1074 % of a block. +Taking 0.1152 % of a block. ```rust calls: Vec<<T as Config>::RuntimeCall> @@ -1382,7 +1426,7 @@ includes bypassing `frame_system::Config::BaseCallFilter`). <details><summary><code>spend_local(amount, beneficiary)</code></summary> -Taking 0.0044 % of a block. +Taking 0.0046 % of a block. ```rust amount: BalanceOf<T, I> @@ -1449,7 +1493,7 @@ The original deposit will no longer be returned. <details><summary><code>spend(asset_kind, amount, beneficiary, valid_from)</code></summary> -Taking 0.0044 % of a block. +Taking 0.0046 % of a block. ```rust asset_kind: Box<T::AssetKind> @@ -1492,7 +1536,7 @@ Emits [`Event::AssetSpendApproved`] if successful. <details><summary><code>payout(index)</code></summary> -Taking 0.0057 % of a block. +Taking 0.0056 % of a block. ```rust index: SpendIndex @@ -1525,7 +1569,7 @@ Emits [`Event::Paid`] if successful. <details><summary><code>check_status(index)</code></summary> -Taking 0.0057 % of a block. +Taking 0.0056 % of a block. ```rust index: SpendIndex diff --git a/docs/api/runtime-constants.md b/docs/api/runtime-constants.md index 329d3c8de..b7810d69b 100644 --- a/docs/api/runtime-constants.md +++ b/docs/api/runtime-constants.md @@ -15,7 +15,7 @@ There are **69** constants from **35** pallets. Block & extrinsics weights: base values and limits. ```rust -value: frame_system::limits::BlockWeights({ base_block: { ref_time: 453383000, proof_size: 0 }, max_block: { ref_time: 2000000000000, proof_size: 18446744073709551615 }, per_class: { normal: { base_extrinsic: { ref_time: 107074000, proof_size: 0 }, max_extrinsic: Some ({ ref_time: 1299892926000, proof_size: 11990383647911208550 }), max_total: Some ({ ref_time: 1500000000000, proof_size: 13835058055282163711 }), reserved: Some ({ ref_time: 0, proof_size: 0 }) }, operational: { base_extrinsic: { ref_time: 107074000, proof_size: 0 }, max_extrinsic: Some ({ ref_time: 1799892926000, proof_size: 16602069666338596454 }), max_total: Some ({ ref_time: 2000000000000, proof_size: 18446744073709551615 }), reserved: Some ({ ref_time: 500000000000, proof_size: 4611686018427387904 }) }, mandatory: { base_extrinsic: { ref_time: 107074000, proof_size: 0 }, max_extrinsic: None (), max_total: None (), reserved: None () } } }) +value: frame_system::limits::BlockWeights({ base_block: { ref_time: 431614000, proof_size: 0 }, max_block: { ref_time: 2000000000000, proof_size: 18446744073709551615 }, per_class: { normal: { base_extrinsic: { ref_time: 108157000, proof_size: 0 }, max_extrinsic: Some ({ ref_time: 1299891843000, proof_size: 11990383647911208550 }), max_total: Some ({ ref_time: 1500000000000, proof_size: 13835058055282163711 }), reserved: Some ({ ref_time: 0, proof_size: 0 }) }, operational: { base_extrinsic: { ref_time: 108157000, proof_size: 0 }, max_extrinsic: Some ({ ref_time: 1799891843000, proof_size: 16602069666338596454 }), max_total: Some ({ ref_time: 2000000000000, proof_size: 18446744073709551615 }), reserved: Some ({ ref_time: 500000000000, proof_size: 4611686018427387904 }) }, mandatory: { base_extrinsic: { ref_time: 108157000, proof_size: 0 }, max_extrinsic: None (), max_total: None (), reserved: None () } } }) ``` </details> @@ -57,7 +57,7 @@ value: U32(2400) The weight of runtime database operations the runtime can invoke. ```rust -value: sp_weights::RuntimeDbWeight({ read: 21040000, write: 104032000 }) +value: sp_weights::RuntimeDbWeight({ read: 14314000, write: 99642000 }) ``` </details> @@ -71,7 +71,7 @@ value: sp_weights::RuntimeDbWeight({ read: 21040000, write: 104032000 }) Get the chain's in-code version. ```rust -value: sp_version::RuntimeVersion({ spec_name: "gdev", impl_name: "duniter-gdev", authoring_version: 1, spec_version: 800, impl_version: 1, apis: ((((104, 122, 212, 74, 211, 127, 3, 194), 1), ((203, 202, 37, 227, 159, 20, 35, 135), 2), ((223, 106, 203, 104, 153, 7, 96, 155), 5), ((55, 227, 151, 252, 124, 145, 245, 228), 2), ((64, 254, 58, 212, 1, 248, 149, 154), 6), ((210, 188, 152, 151, 238, 208, 143, 21), 3), ((247, 139, 39, 139, 229, 63, 69, 76), 2), ((171, 60, 5, 114, 41, 31, 235, 139), 1), ((237, 153, 197, 172, 178, 94, 237, 245), 3), ((188, 157, 137, 144, 79, 91, 146, 63), 1), ((55, 200, 187, 19, 80, 169, 162, 168), 4), ((251, 197, 119, 185, 215, 71, 239, 214), 1))), transaction_version: 1, state_version: 1 }) +value: sp_version::RuntimeVersion({ spec_name: ("gdev"), impl_name: ("duniter-gdev"), authoring_version: 1, spec_version: 800, impl_version: 1, apis: ((((104, 122, 212, 74, 211, 127, 3, 194), 1), ((203, 202, 37, 227, 159, 20, 35, 135), 2), ((223, 106, 203, 104, 153, 7, 96, 155), 5), ((55, 227, 151, 252, 124, 145, 245, 228), 2), ((64, 254, 58, 212, 1, 248, 149, 154), 6), ((210, 188, 152, 151, 238, 208, 143, 21), 3), ((247, 139, 39, 139, 229, 63, 69, 76), 2), ((171, 60, 5, 114, 41, 31, 235, 139), 1), ((237, 153, 197, 172, 178, 94, 237, 245), 3), ((188, 157, 137, 144, 79, 91, 146, 63), 1), ((55, 200, 187, 19, 80, 169, 162, 168), 4), ((251, 197, 119, 185, 215, 71, 239, 214), 1))), transaction_version: 1, system_version: 1 }) ``` </details> @@ -1246,6 +1246,9 @@ value: frame_support::PalletId(((112, 121, 47, 116, 114, 115, 114, 121))) <summary> <code>MaxApprovals</code> </summary> + DEPRECATED: associated with `spend_local` call and will be removed in May 2025. + Refer to <https://github.com/paritytech/polkadot-sdk/pull/5961> for migration to `spend`. + The maximum number of approvals that can wait in the spending queue. NOTE: This parameter is also used within the Bounties Pallet extension if enabled. diff --git a/docs/api/runtime-errors.md b/docs/api/runtime-errors.md index ead935a5d..6f0de162f 100644 --- a/docs/api/runtime-errors.md +++ b/docs/api/runtime-errors.md @@ -1,6 +1,6 @@ # Runtime errors -There are **191** errors from **35** pallets. +There are **192** errors from **35** pallets. <ul> <li>System - 0 @@ -778,6 +778,13 @@ The given length bound for the proposal was too low. Prime account is not a member </details> </li> +<li> +<details> +<summary> +<code>ProposalActive</code> - 11</summary> +Proposal is still active. +</details> +</li> </ul> </li> <li>UniversalDividend - 30 diff --git a/docs/api/runtime-errors.po b/docs/api/runtime-errors.po index f16ca07c1..5438db6c8 100644 --- a/docs/api/runtime-errors.po +++ b/docs/api/runtime-errors.po @@ -198,6 +198,8 @@ msgid "TechnicalCommittee.WrongProposalLength" msgstr "The given length bound for the proposal was too low." msgid "TechnicalCommittee.PrimeAccountNotMember" msgstr "Prime account is not a member" +msgid "TechnicalCommittee.ProposalActive" +msgstr "Proposal is still active." msgid "UniversalDividend.AccountNotAllowedToClaimUds" msgstr "This account is not allowed to claim UDs." msgid "Wot.NotEnoughCerts" diff --git a/docs/api/runtime-events.md b/docs/api/runtime-events.md index d485840ae..527057e9f 100644 --- a/docs/api/runtime-events.md +++ b/docs/api/runtime-events.md @@ -1,6 +1,6 @@ # Runtime events -There are **136** events from **35** pallets. +There are **139** events from **35** pallets. <ul> <li>System - 0 @@ -12,7 +12,7 @@ There are **136** events from **35** pallets. An extrinsic completed successfully. ```rust -dispatch_info: DispatchInfo +dispatch_info: DispatchEventInfo ``` </details> @@ -25,7 +25,7 @@ An extrinsic failed. ```rust dispatch_error: DispatchError -dispatch_info: DispatchInfo +dispatch_info: DispatchEventInfo ``` </details> @@ -1183,6 +1183,44 @@ yes: MemberCount no: MemberCount ``` +</details> +</li> +<li> +<details> +<summary> +<code>Killed(proposal_hash)</code> - 7</summary> +A proposal was killed. + +```rust +proposal_hash: T::Hash +``` + +</details> +</li> +<li> +<details> +<summary> +<code>ProposalCostBurned(proposal_hash, who)</code> - 8</summary> +Some cost for storing a proposal was burned. + +```rust +proposal_hash: T::Hash +who: T::AccountId +``` + +</details> +</li> +<li> +<details> +<summary> +<code>ProposalCostReleased(proposal_hash, who)</code> - 9</summary> +Some cost for storing a proposal was released. + +```rust +proposal_hash: T::Hash +who: T::AccountId +``` + </details> </li> </ul> diff --git a/docs/api/runtime-storages.md b/docs/api/runtime-storages.md index c1bceb5cf..205615059 100644 --- a/docs/api/runtime-storages.md +++ b/docs/api/runtime-storages.md @@ -1,6 +1,6 @@ # Runtime Storage -There are **136** storages from **35** pallets. +There are **139** storages from **35** pallets. <ul> @@ -1587,6 +1587,24 @@ value: gdev_runtime::RuntimeCall </details> </li> +<li> +<details> +<summary> +<code>CostOf</code> +</summary> + Consideration cost created for publishing and storing a proposal. + + Determined by [Config::Consideration] and may be not present for certain proposals (e.g. if + the proposal count at the time of creation was below threshold N). + +```rust +key: primitive_types::H256 +value: (sp_core::crypto::AccountId32, ()) +``` + +</details> +</li> + <li> <details> <summary> @@ -2231,6 +2249,9 @@ value: (bounded_collections::bounded_vec::BoundedVec<pallet_proxy::Announcement< <summary> <code>ProposalCount</code> </summary> + DEPRECATED: associated with `spend_local` call and will be removed in May 2025. + Refer to <https://github.com/paritytech/polkadot-sdk/pull/5961> for migration to `spend`. + Number of proposals that have been made. ```rust @@ -2245,6 +2266,9 @@ value: U32 <summary> <code>Proposals</code> </summary> + DEPRECATED: associated with `spend_local` call and will be removed in May 2025. + Refer to <https://github.com/paritytech/polkadot-sdk/pull/5961> for migration to `spend`. + Proposals that have been made. ```rust @@ -2274,6 +2298,9 @@ value: U64 <summary> <code>Approvals</code> </summary> + DEPRECATED: associated with `spend_local` call and will be removed in May 2025. + Refer to <https://github.com/paritytech/polkadot-sdk/pull/5961> for migration to `spend`. + Proposal indices that have been approved but not yet awarded. ```rust @@ -2312,6 +2339,20 @@ value: pallet_treasury::SpendStatus<(), U64, sp_core::crypto::AccountId32, U32, </details> </li> +<li> +<details> +<summary> +<code>LastSpendPeriod</code> +</summary> + The blocknumber for the last triggered spend period. + +```rust +value: Option<U32> +``` + +</details> +</li> + </ul> </li> -- GitLab