This commit is contained in:
bkchr
2024-02-19 00:50:22 +00:00
parent 572cc67632
commit 619c17b504
4 changed files with 52 additions and 42 deletions
+25 -20
View File
@@ -286,6 +286,14 @@ DAOs can utilize multisig accounts to ensure that decisions are made collectivel
<li>Any multisig account owener can execute proposal if it's approved by enough signers. (Dave in the diagram)</li>
</ul>
<h3 id="state-transition-functions"><a class="header" href="#state-transition-functions">State Transition Functions</a></h3>
<p>having the following enum to store the call or the hash:</p>
<pre><pre class="playground"><code class="language-rust"><span class="boring">#![allow(unused)]
</span><span class="boring">fn main() {
</span>enum CallOrHash&lt;T: Config&gt; {
Call(&lt;T as Config&gt;::RuntimeCall),
Hash(T::Hash),
}
<span class="boring">}</span></code></pre></pre>
<ul>
<li><code>create_multisig</code> - Create a multisig account with a given threshold and initial signers. (Needs Deposit)</li>
</ul>
@@ -327,7 +335,7 @@ DAOs can utilize multisig accounts to ensure that decisions are made collectivel
/// # Arguments
///
/// * `multisig_account` - The multisig account ID.
/// * `call` - The dispatchable call to be executed.
/// * `call_or_hash` - The enum having the call or the hash of the call to be approved and executed later.
///
/// # Errors
///
@@ -337,7 +345,7 @@ DAOs can utilize multisig accounts to ensure that decisions are made collectivel
pub fn start_proposal(
origin: OriginFor&lt;T&gt;,
multisig_account: T::AccountId,
call_hash: T::Hash,
call_or_hash: CallOrHash,
) -&gt; DispatchResult
<span class="boring">}</span></code></pre></pre>
<ul>
@@ -354,7 +362,7 @@ DAOs can utilize multisig accounts to ensure that decisions are made collectivel
/// # Arguments
///
/// * `multisig_account` - The multisig account ID.
/// * `call_hash` - The hash of the call to be approved. (This will be the hash of the call that was used in `start_proposal`)
/// * `call_or_hash` - The enum having the call or the hash of the call to be approved.
///
/// # Errors
///
@@ -365,7 +373,7 @@ DAOs can utilize multisig accounts to ensure that decisions are made collectivel
pub fn approve(
origin: OriginFor&lt;T&gt;,
multisig_account: T::AccountId,
call_hash: T::Hash,
call_or_hash: CallOrHash,
) -&gt; DispatchResult
<span class="boring">}</span></code></pre></pre>
<ul>
@@ -383,7 +391,7 @@ DAOs can utilize multisig accounts to ensure that decisions are made collectivel
/// # Arguments
///
/// * `multisig_account` - The multisig account ID.
/// * `call_hash` - The hash of the call to be approved. (This will be the hash of the call that was used in `start_proposal`)
/// * `call_or_hash` - The enum having the call or the hash of the call to be rejected.
///
/// # Errors
///
@@ -395,7 +403,7 @@ DAOs can utilize multisig accounts to ensure that decisions are made collectivel
pub fn reject(
origin: OriginFor&lt;T&gt;,
multisig_account: T::AccountId,
call_hash: T::Hash,
call_or_hash: CallOrHash,
) -&gt; DispatchResult
<span class="boring">}</span></code></pre></pre>
<ul>
@@ -415,17 +423,19 @@ DAOs can utilize multisig accounts to ensure that decisions are made collectivel
/// # Arguments
///
/// * `multisig_account` - The multisig account ID.
/// * `call` - The call to be executed.
/// * `call_or_hash` - We should have gotten the RuntimeCall (preimage) and stored it in the proposal by the time the extrinsic is called.
///
/// # Errors
///
/// * `MultisigNotFound` - The multisig account does not exist.
/// * `UnAuthorizedSigner` - The caller is not an signer of the multisig account.
/// * `NotEnoughApprovers` - approvers don't exceed the threshold.
/// * `ProposalNotFound` - The proposal does not exist.
/// * `CallPreImageNotFound` - The proposal doesn't have the preimage of the call in the state.
pub fn execute_proposal(
origin: OriginFor&lt;T&gt;,
multisig_account: T::AccountId,
call: Box&lt;&lt;T as Config&gt;::RuntimeCall&gt;,
call_or_hash: CallOrHash,
) -&gt; DispatchResult
<span class="boring">}</span></code></pre></pre>
<ul>
@@ -445,7 +455,7 @@ DAOs can utilize multisig accounts to ensure that decisions are made collectivel
/// # Arguments
///
/// * `origin` - The origin multisig account who wants to cancel the proposal.
/// * `call_hash` - The hash of the call to be canceled. (This will be the hash of the call that was used in `start_proposal`)
/// * `call_or_hash` - The call or hash of the call to be canceled.
///
/// # Errors
///
@@ -454,7 +464,7 @@ DAOs can utilize multisig accounts to ensure that decisions are made collectivel
pub fn cancel_proposal(
origin: OriginFor&lt;T&gt;,
multisig_account: T::AccountId,
call_hash: T::Hash) -&gt; DispatchResult
call_or_hash: CallOrHash) -&gt; DispatchResult
<span class="boring">}</span></code></pre></pre>
<ul>
<li><code>cancel_own_proposal</code> - Cancel a multisig proposal started by the caller in case no other signers approved it yet. (Releases Deposit)</li>
@@ -471,7 +481,7 @@ DAOs can utilize multisig accounts to ensure that decisions are made collectivel
/// # Arguments
///
/// * `multisig_account` - The multisig account ID.
/// * `call_hash` - The hash of the call to be canceled. (This will be the hash of the call that was used in `start_proposal`)
/// * `call_or_hash` - The hash of the call to be canceled.
///
/// # Errors
///
@@ -480,7 +490,7 @@ DAOs can utilize multisig accounts to ensure that decisions are made collectivel
pub fn cancel_own_proposal(
origin: OriginFor&lt;T&gt;,
multisig_account: T::AccountId,
call_hash: T::Hash,
call_or_hash: CallOrHash,
) -&gt; DispatchResult
<span class="boring">}</span></code></pre></pre>
<ul>
@@ -632,7 +642,6 @@ pub type PendingProposals&lt;T: Config&gt; = StorageDoubleMap&lt;
pub signers: BoundedBTreeSet&lt;T::AccountId, T::MaxSignatories&gt;,
/// The threshold of approvers required for the multisig account to be able to execute a call.
pub threshold: u32,
pub creator: T::AccountId,
pub deposit: BalanceOf&lt;T&gt;,
}
<span class="boring">}</span></code></pre></pre>
@@ -704,7 +713,7 @@ We have the following extrinsics:</p>
</span>pub fn start_proposal(
origin: OriginFor&lt;T&gt;,
multisig_account: T::AccountId,
call_hash: T::Hash,
call_or_hash: CallOrHash,
)
<span class="boring">}</span></code></pre></pre>
<pre><pre class="playground"><code class="language-rust"><span class="boring">#![allow(unused)]
@@ -712,7 +721,7 @@ We have the following extrinsics:</p>
</span>pub fn approve(
origin: OriginFor&lt;T&gt;,
multisig_account: T::AccountId,
call_hash: T::Hash,
call_or_hash: CallOrHash,
)
<span class="boring">}</span></code></pre></pre>
<pre><pre class="playground"><code class="language-rust"><span class="boring">#![allow(unused)]
@@ -720,7 +729,7 @@ We have the following extrinsics:</p>
</span>pub fn execute_proposal(
origin: OriginFor&lt;T&gt;,
multisig_account: T::AccountId,
call: Box&lt;&lt;T as Config&gt;::RuntimeCall&gt;,
call_or_hash: CallOrHash,
)
<span class="boring">}</span></code></pre></pre>
<p>The main takeway is that we don't need to pass the threshold and other signatories in the extrinsics. This is because we already have the threshold and signatories in the state (only once).</p>
@@ -760,14 +769,10 @@ We have the following extrinsics:</p>
<h2 id="future-directions-and-related-material"><a class="header" href="#future-directions-and-related-material">Future Directions and Related Material</a></h2>
<ul>
<li><input disabled="" type="checkbox"/>
Batch proposals. The ability to batch multiple calls into one proposal.</li>
<li><input disabled="" type="checkbox"/>
Batch addition/removal of signers.</li>
<li><input disabled="" type="checkbox"/>
Add expiry to proposals. After a certain time, proposals will not accept any more approvals or executions and will be deleted.</li>
<li><input disabled="" type="checkbox"/>
Add extra identifier other than call_hash to proposals (e.g. nonce). This will allow same call to be proposed multiple times and be in pending state.</li>
<li><input disabled="" type="checkbox"/>
Implement call filters. This will allow multisig accounts to only accept certain calls.</li>
</ul>