Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update preimage-related docs #512

Merged
merged 7 commits into from
Jan 24, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions builders/pallets-precompiles/pallets/.pages
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ nav:
- index.md
- 'Democracy': 'democracy.md'
- 'Parachain Staking': 'staking.md'
- 'Preimage': 'preimage.md'
- 'Proxy': 'proxy.md'
- 'Randomness': 'randomness.md'
- 'Utility': 'utility.md'
Expand Down
31 changes: 18 additions & 13 deletions builders/pallets-precompiles/pallets/democracy.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,22 @@ Some of the functionality of the democracy pallet is also available through a de

This guide will provide an overview of the extrinsics, storage methods, and getters for the pallet constants available in the democracy pallet on Moonbeam.

## Democracy Pallet Interface {: #parachain-staking-pallet-interface }
## Democracy Pallet Interface {: #democracy-pallet-interface }

### Extrinsics {: #extrinsics }

The democracy pallet provides the following extrinsics (functions):

- **delegate**(to, conviction, balance) - delegates the voting power, with some given conviction, of the sending account to a given account. The balance delegated is locked for as long as it's delegated, and thereafter for the time appropriate for the conviction's lock period. The sending account must be delegating already or have no voting activity. Emits a `Delegated` event
- **enactProposal**(proposalHash, index) - enacts a proposal from a referendum given the proposal hash and the index of the referendum
- **noteImminentPreimage**(encodedProposal) - registers a preimage for an upcoming proposal in the dispatch queue given the encoded preimage of a proposal. Emits a `PreimageNoted` event
- **notePreimage**(encodedProposal) - registers a preimage for an upcoming proposal given the encoded preimage of a proposal. This odesn't require the proposal to be in the dispatch queue but does require a deposit that is returned once enacted. Emits a `PreimageNoted` event
- **propose**(proposalHash, value) - submits a proposal given the preimage hash and the deposit amount, which must be at least the minimum deposit. Emits a `Proposed` event
- **reapPreimage**(proposalHash, proposalLenUpperBound) - removes an expired proposal preimage and collects the deposit. This will only work after the number of blocks in the voting period have passed and if it's the same account that created the preimage is making the call. If it's a different account, then the call must be made after the number of blocks in the enactment period. Emits a `PreimageReaped` event
- **enactProposal**(proposalHash, index) - *deprecated as of runtime 2000* - enacts a proposal from a referendum given the proposal hash and the index of the referendum
- **noteImminentPreimage**(encodedProposal) - *deprecated as of runtime 2000* - registers a preimage for an upcoming proposal in the dispatch queue given the encoded preimage of a proposal. Emits a `PreimageNoted` event
- **notePreimage**(encodedProposal) - *deprecated as of runtime 2000* - registers a preimage for an upcoming proposal given the encoded preimage of a proposal. This odesn't require the proposal to be in the dispatch queue but does require a deposit that is returned once enacted. Emits a `PreimageNoted` event. **This extrinsic is now accessible through the [preimage pallet](/builders/pallets-precompiles/pallets/preimage/#extrinsics){target=_blank}**
- **propose**(proposal, value) - submits a proposal given the proposal and the deposit amount, which must be at least the minimum deposit. Emits a `Proposed` event. The proposal can be one of three types:
- `Legacy` - requires a Blake2-256 preimage hash with no preimage length. This type can no longer be created and temporarily exists to support transitioning from legacy state
- `Inline` - requires a bounded `Call`. Its encoding must be at most 128 bytes
- `Lookup` - requires a Blake2-256 preimage hash along with the length of the preimage

- **reapPreimage**(proposalHash, proposalLenUpperBound) - *deprecated as of runtime 2000* - removes an expired proposal preimage and collects the deposit. This will only work after the number of blocks in the voting period have passed and if it's the same account that created the preimage is making the call. If it's a different account, then the call must be made after the number of blocks in the enactment period. Emits a `PreimageReaped` event
- **removeOtherVote**(target, index) - removes a vote for a referendum given the account of the vote to be removed for and the index of the referendum. If the account passed in is the signer, then the functionality is the same as the `removeVote` function; otherwise the vote must have expired because the voter lost the referendum or the conviction period is over
- **removeVote**(index) - removes a vote for a referendum given the index of the referendum. The vote can only be removed if the referendum was cancelled, is ongoing, it ended and the vote was in opposition to the result, if there was no conviction to the account's vote, or if the account made a split vote
- **second**(proposal, secondsUpperBound) - seconds a proposal signaling agreement with the proposal given the index of the proposal and an upper bound on the current number of seconds on the proposal
Expand All @@ -39,9 +43,9 @@ Some of the extrinsics in the democracy pallet are subject to votes of the *Tech

- **cancelProposal**(propIndex) - removes a proposal given the index of the proposal to cancel. Cancellations are in the hands of the *Root* account or if *3/5th of the Technical Committee* vote to cancel the proposal
- **emergencyCancel**(refIndex) - schedules an emergency cancellation of a referendum given the index of the referendum to cancel. Emergency cancellations are in the hands of the *Root* account or if *3/5th of the Council* vote to cancel the referendum
- **externalPropose**(proposalHash) - schedules a referendum to be brought to a vote once it is legal to schedule an external referendum given a proposal hash. If at least *1/2 of the Council* vote in approval the referendum will be tabled next
- **externalProposeDefault**(proposalHash) - schedules a negative-turnout-bias referendum to be brought to a vote next once it is legal to schedule an external referendum given the preimage hash of a proposal. If at least *3/5th of the Council* vote in approval the referendum will be tabled next
- **exernalProposeMajority**(proposalHash) - schedules a majority-carries referendum to be brought to a vote next once it is legal to schedule an external referendum given the preimage hash of a proposal. If at least *3/5th of the Council* vote in approval the referendum will be tabled next
- **externalPropose**(proposal) - schedules a referendum to be brought to a vote once it is legal to schedule an external referendum given a proposal hash. If at least *1/2 of the Council* vote in approval the referendum will be tabled next. Please refer to the three types of proposals, in the **propose** extrinsic description above
- **externalProposeDefault**(proposal) - schedules a negative-turnout-bias referendum to be brought to a vote next once it is legal to schedule an external referendum given the preimage hash of a proposal. If at least *3/5th of the Council* vote in approval the referendum will be tabled next. Please refer to the three types of proposals, in the **propose** extrinsic description above
- **exernalProposeMajority**(proposal) - schedules a majority-carries referendum to be brought to a vote next once it is legal to schedule an external referendum given the preimage hash of a proposal. If at least *3/5th of the Council* vote in approval the referendum will be tabled next. Please refer to the three types of proposals, in the **propose** extrinsic description above
- **fastTrack**(proposalHash, votingPeriod, delay) - schedules a currently externally-proposed majority-carries referendum to be brought to a vote immediately given the proposal hash, the period allowed for voting on the proposal, and the number of blocks after an approval and it is enacted. If there is no externally-proposed referendum currently, or if there is one but it is not a majority-carries referendum then it fails. If at least *1/2 of the Technical Committee* vote in approval the referendum will be tabled immediately
- **noteImminentPreimageOperational**(encodedProposal) - registers a preimage for an upcoming proposal in the dispatch queue given the encoded preimage of a proposal. Emits a `PreimageNoted` event. Must be called by a member of the *Council*
- **notePreimageOperational**(encodedProposal) - registers a preimage for an upcoming proposal given the encoded preimage of a proposal. This odesn't require the proposal to be in the dispatch queue but does require a deposit that is returned once enacted. Emits a `PreimageNoted` event. Must be called by a member of the *Council*
Expand All @@ -50,7 +54,7 @@ Some of the extrinsics in the democracy pallet are subject to votes of the *Tech
There are also some extrinsics in the democracy pallet that can only be dispatched by the *root* account:

- **blacklist**(proposalHash, maybeRefIndex) - permanently places a proposal given a proposal hash into the blacklist which prevents it from ever being proposed again. If called on a queued public or external proposal, then this will result in it being removed. If the `maybeRefIndex` supplied is an active referendum that corresponds to the proposal hash, the proposal will be cancelled
- **cancelQueued**(which) - cancels a proposal queued for enactment given the index of the referendum to cancel
- **cancelQueued**(which) - *deprecated as of runtime 2000* - cancels a proposal queued for enactment given the index of the referendum to cancel
- **cancelReferendum**(refIndex) - removes a referendum given the index of the referendum to cancel
- **clearPublicProposals**() - clears all public proposals

Expand All @@ -65,12 +69,11 @@ The democracy pallet includes the following read-only storage methods to obtain
- **lowestUnbaked**() - returns the lowest referendum index that corresponds to an unbaked referendum
- **nextExternal**() - returns the next referendum to be brought to a vote for whenever it would be valid to vote on an external proposal
- **palletVersion**() - returns the current pallet version
- **preimages**(H256) - returns the map of proposal preimage hashes of all preimages or for a given preimage hash along with who registered it (`provider`), their deposit, and the block number at which it was deposited (`since`)
- **preimages**(H256) - *deprecated as of runtime 2000* - **this storage item is now accessible through the [preimage pallet](/builders/pallets-precompiles/pallets/preimage/#storage-methods){target=_blank}**
- **publicPropCount**() - returns the number of public proposals that have been made so far
- **publicProps**() - returns a record of the public proposals
- **referendumCount**() - returns the number of referenda started so far
- **referendumInfoOf**() - returns information for a referendum given the referendum's index
- **storageVersion**() - returns the storage version of the pallet
- **votingOf**(AccountId20) - returns a record of all of the votes for a particular voter given the address of the voter

### Pallet Constants {: #constants }
Expand All @@ -83,8 +86,10 @@ The democracy pallet includes the following read-only functions to obtain pallet
- **instantAllowed**() - returns a boolean indicating whether an emergency origin is even allowed to happen
- **launchPeriod**() - returns how often (in blocks) new public referenda are launched
- **maxProposals**() - returns the maximum number of public proposals that can exist at any time
- **maxBlacklisted**() - returns the maximum number of items which can be blacklisted
- **maxDeposits**() - returns the maximum number of deposits a public proposal may have at any time
- **maxVotes**() - returns the maximum number of votes for an account
- **minimumDeposit**() - returns the minimum amount to be used as a deposit for a public referendum proposal
- **preimageByteDeposit**() - returns the amount of balance that must be deposited per byte of preimage stored
- **preimageByteDeposit**() - *deprecated as of runtime 2000* - returns the amount of balance that must be deposited per byte of preimage stored
- **voteLockingPeriod**() - returns the minimum period of vote locking
- **votingPeriod**() - returns how often (in blocks) to check for new votes
36 changes: 36 additions & 0 deletions builders/pallets-precompiles/pallets/preimage.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
---
title: Preimage Pallet
description: Learn about the available extrinsics and storage methods for the preimage pallet on Moonbeam, which are used to store and manage on-chain preimages.
keywords: democracy, substrate, pallet, moonbeam, polkadot, preimage
---

# The Preimage Pallet

![Preimage Moonbeam Banner](/images/builders/pallets-precompiles/pallets/preimage-banner.png)

## Introduction {: #introduction }

The preimage pallet allows for the users and the runtime to store the preimage of a hash on chain. This can be used by other pallets for storing and managing large byte-blobs. For example, token holders can submit a democracy proposal through the democracy pallet using a preimage hash.

Some of the functionality of the preimage pallet is also available through the democracy precompile. The precompile is a Solidity interface that enables you to perform governance functions using the Ethereum API. Please refer to the [Democracy Precompile](/builders/pallets-precompiles/precompiles/democracy){target=_blank} guide for more information.

This guide will provide an overview of the extrinsics, storage methods, and getters for the pallet constants available in the preimage pallet on Moonbeam.

## Preimage Pallet Interface {: #preimage-pallet-interface }

### Extrinsics {: #extrinsics }

The preimage pallet provides the following extrinsics (functions):

- **notePreimage**(encodedProposal) - registers a preimage for an upcoming proposal given the encoded preimage of a proposal. If the preimage was previously requested, no fees or deposits are taken for providing the preimage. Otherwise, a deposit is taken proportional to the size of the preimage. Emits a `Noted` event
- **requestPreimage**(bytes) - requests a preimage be uploaded to the chain without paying any fees or deposits. If the preimage requests has already been provided on-chain, we unreserve any deposit a user may have paid, and take the control of the preimage out of their hands. Emits a `Requested` event
eshaben marked this conversation as resolved.
Show resolved Hide resolved
- **unnotePreimage**(hash) - clears an unrequested preimage from the runtime storage given the hash of the preimage to be removed. Emits a `Cleared` event
- **unrequestPreimage**(hash) - clears a previously made request for a preimage. Emits a `Cleared` event

### Storage Methods {: #storage-methods }

The preimage pallet includes the following read-only storage methods to obtain chain state data:

- **palletVersion**() - returns the current pallet version
- **preimageFor**((H256, u32)) - returns a list of the proposal hashes of all preimages along with their associated data. If given a proposal hash and the length of the associated data, a specific preimage is returned
- **statusFor**(H256) - returns the request status of all preimages or for a given preimage hash
Loading