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

permission for framework #14605

Merged
merged 2 commits into from
Jan 16, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
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
111 changes: 110 additions & 1 deletion aptos-move/framework/aptos-framework/doc/aptos_governance.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,10 @@ on a proposal multiple times as long as the total voting power of these votes do
- [Struct `CreateProposal`](#0x1_aptos_governance_CreateProposal)
- [Struct `Vote`](#0x1_aptos_governance_Vote)
- [Struct `UpdateConfig`](#0x1_aptos_governance_UpdateConfig)
- [Struct `GovernancePermission`](#0x1_aptos_governance_GovernancePermission)
- [Constants](#@Constants_0)
- [Function `check_governance_permission`](#0x1_aptos_governance_check_governance_permission)
- [Function `grant_permission`](#0x1_aptos_governance_grant_permission)
- [Function `store_signer_cap`](#0x1_aptos_governance_store_signer_cap)
- [Function `initialize`](#0x1_aptos_governance_initialize)
- [Function `update_governance_config`](#0x1_aptos_governance_update_governance_config)
Expand Down Expand Up @@ -109,6 +112,7 @@ on a proposal multiple times as long as the total voting power of these votes do
<b>use</b> <a href="governance_proposal.md#0x1_governance_proposal">0x1::governance_proposal</a>;
<b>use</b> <a href="../../aptos-stdlib/doc/math64.md#0x1_math64">0x1::math64</a>;
<b>use</b> <a href="../../aptos-stdlib/../move-stdlib/doc/option.md#0x1_option">0x1::option</a>;
<b>use</b> <a href="permissioned_signer.md#0x1_permissioned_signer">0x1::permissioned_signer</a>;
<b>use</b> <a href="randomness_config.md#0x1_randomness_config">0x1::randomness_config</a>;
<b>use</b> <a href="reconfiguration_with_dkg.md#0x1_reconfiguration_with_dkg">0x1::reconfiguration_with_dkg</a>;
<b>use</b> <a href="../../aptos-stdlib/../move-stdlib/doc/signer.md#0x1_signer">0x1::signer</a>;
Expand Down Expand Up @@ -642,6 +646,33 @@ Event emitted when the governance configs are updated.
</dl>


</details>

<a id="0x1_aptos_governance_GovernancePermission"></a>

## Struct `GovernancePermission`



<pre><code><b>struct</b> <a href="aptos_governance.md#0x1_aptos_governance_GovernancePermission">GovernancePermission</a> <b>has</b> <b>copy</b>, drop, store
</code></pre>



<details>
<summary>Fields</summary>


<dl>
<dt>
<code>dummy_field: bool</code>
</dt>
<dd>

</dd>
</dl>


</details>

<a id="@Constants_0"></a>
Expand Down Expand Up @@ -738,6 +769,16 @@ The proposal in the argument is not a partial voting proposal.



<a id="0x1_aptos_governance_ENO_GOVERNANCE_PERMISSION"></a>

Current permissioned signer cannot perform governance operations.


<pre><code><b>const</b> <a href="aptos_governance.md#0x1_aptos_governance_ENO_GOVERNANCE_PERMISSION">ENO_GOVERNANCE_PERMISSION</a>: u64 = 16;
</code></pre>



<a id="0x1_aptos_governance_ENO_VOTING_POWER"></a>

The specified stake pool must be part of the validator set
Expand Down Expand Up @@ -827,6 +868,59 @@ Proposal metadata attribute keys.



<a id="0x1_aptos_governance_check_governance_permission"></a>

## Function `check_governance_permission`

Permissions


<pre><code><b>fun</b> <a href="aptos_governance.md#0x1_aptos_governance_check_governance_permission">check_governance_permission</a>(s: &<a href="../../aptos-stdlib/../move-stdlib/doc/signer.md#0x1_signer">signer</a>)
</code></pre>



<details>
<summary>Implementation</summary>


<pre><code>inline <b>fun</b> <a href="aptos_governance.md#0x1_aptos_governance_check_governance_permission">check_governance_permission</a>(s: &<a href="../../aptos-stdlib/../move-stdlib/doc/signer.md#0x1_signer">signer</a>) {
<b>assert</b>!(
<a href="permissioned_signer.md#0x1_permissioned_signer_check_permission_exists">permissioned_signer::check_permission_exists</a>(s, <a href="aptos_governance.md#0x1_aptos_governance_GovernancePermission">GovernancePermission</a> {}),
<a href="../../aptos-stdlib/../move-stdlib/doc/error.md#0x1_error_permission_denied">error::permission_denied</a>(<a href="aptos_governance.md#0x1_aptos_governance_ENO_GOVERNANCE_PERMISSION">ENO_GOVERNANCE_PERMISSION</a>),
);
}
</code></pre>



</details>

<a id="0x1_aptos_governance_grant_permission"></a>

## Function `grant_permission`

Grant permission to perform governance operations on behalf of the master signer.


<pre><code><b>public</b> <b>fun</b> <a href="aptos_governance.md#0x1_aptos_governance_grant_permission">grant_permission</a>(master: &<a href="../../aptos-stdlib/../move-stdlib/doc/signer.md#0x1_signer">signer</a>, <a href="permissioned_signer.md#0x1_permissioned_signer">permissioned_signer</a>: &<a href="../../aptos-stdlib/../move-stdlib/doc/signer.md#0x1_signer">signer</a>)
</code></pre>



<details>
<summary>Implementation</summary>


<pre><code><b>public</b> <b>fun</b> <a href="aptos_governance.md#0x1_aptos_governance_grant_permission">grant_permission</a>(master: &<a href="../../aptos-stdlib/../move-stdlib/doc/signer.md#0x1_signer">signer</a>, <a href="permissioned_signer.md#0x1_permissioned_signer">permissioned_signer</a>: &<a href="../../aptos-stdlib/../move-stdlib/doc/signer.md#0x1_signer">signer</a>) {
<a href="permissioned_signer.md#0x1_permissioned_signer_authorize_unlimited">permissioned_signer::authorize_unlimited</a>(master, <a href="permissioned_signer.md#0x1_permissioned_signer">permissioned_signer</a>, <a href="aptos_governance.md#0x1_aptos_governance_GovernancePermission">GovernancePermission</a> {})
}
</code></pre>



</details>

<a id="0x1_aptos_governance_store_signer_cap"></a>

## Function `store_signer_cap`
Expand Down Expand Up @@ -1310,6 +1404,7 @@ Return proposal_id when a proposal is successfully created.
metadata_hash: <a href="../../aptos-stdlib/../move-stdlib/doc/vector.md#0x1_vector">vector</a>&lt;u8&gt;,
is_multi_step_proposal: bool,
): u64 <b>acquires</b> <a href="aptos_governance.md#0x1_aptos_governance_GovernanceConfig">GovernanceConfig</a>, <a href="aptos_governance.md#0x1_aptos_governance_GovernanceEvents">GovernanceEvents</a> {
<a href="aptos_governance.md#0x1_aptos_governance_check_governance_permission">check_governance_permission</a>(proposer);
<b>let</b> proposer_address = <a href="../../aptos-stdlib/../move-stdlib/doc/signer.md#0x1_signer_address_of">signer::address_of</a>(proposer);
<b>assert</b>!(
<a href="stake.md#0x1_stake_get_delegated_voter">stake::get_delegated_voter</a>(stake_pool) == proposer_address,
Expand Down Expand Up @@ -1542,6 +1637,7 @@ cannot vote on the proposal even after partial governance voting is enabled.
voting_power: u64,
should_pass: bool,
) <b>acquires</b> <a href="aptos_governance.md#0x1_aptos_governance_ApprovedExecutionHashes">ApprovedExecutionHashes</a>, <a href="aptos_governance.md#0x1_aptos_governance_VotingRecords">VotingRecords</a>, <a href="aptos_governance.md#0x1_aptos_governance_VotingRecordsV2">VotingRecordsV2</a>, <a href="aptos_governance.md#0x1_aptos_governance_GovernanceEvents">GovernanceEvents</a> {
<a href="permissioned_signer.md#0x1_permissioned_signer_assert_master_signer">permissioned_signer::assert_master_signer</a>(voter);
<b>let</b> voter_address = <a href="../../aptos-stdlib/../move-stdlib/doc/signer.md#0x1_signer_address_of">signer::address_of</a>(voter);
<b>assert</b>!(<a href="stake.md#0x1_stake_get_delegated_voter">stake::get_delegated_voter</a>(stake_pool) == voter_address, <a href="../../aptos-stdlib/../move-stdlib/doc/error.md#0x1_error_invalid_argument">error::invalid_argument</a>(<a href="aptos_governance.md#0x1_aptos_governance_ENOT_DELEGATED_VOTER">ENOT_DELEGATED_VOTER</a>));

Expand Down Expand Up @@ -2118,7 +2214,20 @@ Return a signer for making changes to 0x1 as part of on-chain governance proposa


<pre><code><b>pragma</b> verify = <b>true</b>;
<b>pragma</b> aborts_if_is_strict;
<b>pragma</b> aborts_if_is_partial;
</code></pre>




<a id="0x1_aptos_governance_AbortsIfPermissionedSigner"></a>


<pre><code><b>schema</b> <a href="aptos_governance.md#0x1_aptos_governance_AbortsIfPermissionedSigner">AbortsIfPermissionedSigner</a> {
s: <a href="../../aptos-stdlib/../move-stdlib/doc/signer.md#0x1_signer">signer</a>;
<b>let</b> perm = <a href="aptos_governance.md#0x1_aptos_governance_GovernancePermission">GovernancePermission</a> {};
<b>aborts_if</b> !<a href="permissioned_signer.md#0x1_permissioned_signer_spec_check_permission_exists">permissioned_signer::spec_check_permission_exists</a>(s, perm);
}
</code></pre>


Expand Down
111 changes: 110 additions & 1 deletion aptos-move/framework/aptos-framework/doc/code.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,11 @@ This module supports functionality related to code management.
- [Struct `ModuleMetadata`](#0x1_code_ModuleMetadata)
- [Struct `UpgradePolicy`](#0x1_code_UpgradePolicy)
- [Struct `PublishPackage`](#0x1_code_PublishPackage)
- [Struct `CodePublishingPermission`](#0x1_code_CodePublishingPermission)
- [Struct `AllowedDep`](#0x1_code_AllowedDep)
- [Constants](#@Constants_0)
- [Function `check_code_publishing_permission`](#0x1_code_check_code_publishing_permission)
- [Function `grant_permission`](#0x1_code_grant_permission)
- [Function `upgrade_policy_arbitrary`](#0x1_code_upgrade_policy_arbitrary)
- [Function `upgrade_policy_compat`](#0x1_code_upgrade_policy_compat)
- [Function `upgrade_policy_immutable`](#0x1_code_upgrade_policy_immutable)
Expand Down Expand Up @@ -50,6 +53,7 @@ This module supports functionality related to code management.
<b>use</b> <a href="../../aptos-stdlib/../move-stdlib/doc/features.md#0x1_features">0x1::features</a>;
<b>use</b> <a href="object.md#0x1_object">0x1::object</a>;
<b>use</b> <a href="../../aptos-stdlib/../move-stdlib/doc/option.md#0x1_option">0x1::option</a>;
<b>use</b> <a href="permissioned_signer.md#0x1_permissioned_signer">0x1::permissioned_signer</a>;
<b>use</b> <a href="../../aptos-stdlib/../move-stdlib/doc/signer.md#0x1_signer">0x1::signer</a>;
<b>use</b> <a href="../../aptos-stdlib/../move-stdlib/doc/string.md#0x1_string">0x1::string</a>;
<b>use</b> <a href="system_addresses.md#0x1_system_addresses">0x1::system_addresses</a>;
Expand Down Expand Up @@ -300,6 +304,33 @@ Event emitted when code is published to an address.
</dl>


</details>

<a id="0x1_code_CodePublishingPermission"></a>

## Struct `CodePublishingPermission`



<pre><code><b>struct</b> <a href="code.md#0x1_code_CodePublishingPermission">CodePublishingPermission</a> <b>has</b> <b>copy</b>, drop, store
</code></pre>



<details>
<summary>Fields</summary>


<dl>
<dt>
<code>dummy_field: bool</code>
</dt>
<dd>

</dd>
</dl>


</details>

<a id="0x1_code_AllowedDep"></a>
Expand Down Expand Up @@ -413,6 +444,16 @@ Not the owner of the package registry.



<a id="0x1_code_ENO_CODE_PERMISSION"></a>

Current permissioned signer cannot publish codes.


<pre><code><b>const</b> <a href="code.md#0x1_code_ENO_CODE_PERMISSION">ENO_CODE_PERMISSION</a>: u64 = 11;
</code></pre>



<a id="0x1_code_EPACKAGE_DEP_MISSING"></a>

Dependency could not be resolved to any published package.
Expand Down Expand Up @@ -443,6 +484,59 @@ Cannot downgrade a package's upgradability policy



<a id="0x1_code_check_code_publishing_permission"></a>

## Function `check_code_publishing_permission`

Permissions


<pre><code><b>public</b>(<b>friend</b>) <b>fun</b> <a href="code.md#0x1_code_check_code_publishing_permission">check_code_publishing_permission</a>(s: &<a href="../../aptos-stdlib/../move-stdlib/doc/signer.md#0x1_signer">signer</a>)
</code></pre>



<details>
<summary>Implementation</summary>


<pre><code><b>public</b>(<b>friend</b>) <b>fun</b> <a href="code.md#0x1_code_check_code_publishing_permission">check_code_publishing_permission</a>(s: &<a href="../../aptos-stdlib/../move-stdlib/doc/signer.md#0x1_signer">signer</a>) {
<b>assert</b>!(
<a href="permissioned_signer.md#0x1_permissioned_signer_check_permission_exists">permissioned_signer::check_permission_exists</a>(s, <a href="code.md#0x1_code_CodePublishingPermission">CodePublishingPermission</a> {}),
<a href="../../aptos-stdlib/../move-stdlib/doc/error.md#0x1_error_permission_denied">error::permission_denied</a>(<a href="code.md#0x1_code_ENO_CODE_PERMISSION">ENO_CODE_PERMISSION</a>),
);
}
</code></pre>



</details>

<a id="0x1_code_grant_permission"></a>

## Function `grant_permission`

Grant permission to publish code on behalf of the master signer.


<pre><code><b>public</b> <b>fun</b> <a href="code.md#0x1_code_grant_permission">grant_permission</a>(master: &<a href="../../aptos-stdlib/../move-stdlib/doc/signer.md#0x1_signer">signer</a>, <a href="permissioned_signer.md#0x1_permissioned_signer">permissioned_signer</a>: &<a href="../../aptos-stdlib/../move-stdlib/doc/signer.md#0x1_signer">signer</a>)
</code></pre>



<details>
<summary>Implementation</summary>


<pre><code><b>public</b> <b>fun</b> <a href="code.md#0x1_code_grant_permission">grant_permission</a>(master: &<a href="../../aptos-stdlib/../move-stdlib/doc/signer.md#0x1_signer">signer</a>, <a href="permissioned_signer.md#0x1_permissioned_signer">permissioned_signer</a>: &<a href="../../aptos-stdlib/../move-stdlib/doc/signer.md#0x1_signer">signer</a>) {
<a href="permissioned_signer.md#0x1_permissioned_signer_authorize_unlimited">permissioned_signer::authorize_unlimited</a>(master, <a href="permissioned_signer.md#0x1_permissioned_signer">permissioned_signer</a>, <a href="code.md#0x1_code_CodePublishingPermission">CodePublishingPermission</a> {})
}
</code></pre>



</details>

<a id="0x1_code_upgrade_policy_arbitrary"></a>

## Function `upgrade_policy_arbitrary`
Expand Down Expand Up @@ -598,6 +692,7 @@ package.


<pre><code><b>public</b> <b>fun</b> <a href="code.md#0x1_code_publish_package">publish_package</a>(owner: &<a href="../../aptos-stdlib/../move-stdlib/doc/signer.md#0x1_signer">signer</a>, pack: <a href="code.md#0x1_code_PackageMetadata">PackageMetadata</a>, <a href="code.md#0x1_code">code</a>: <a href="../../aptos-stdlib/../move-stdlib/doc/vector.md#0x1_vector">vector</a>&lt;<a href="../../aptos-stdlib/../move-stdlib/doc/vector.md#0x1_vector">vector</a>&lt;u8&gt;&gt;) <b>acquires</b> <a href="code.md#0x1_code_PackageRegistry">PackageRegistry</a> {
<a href="code.md#0x1_code_check_code_publishing_permission">check_code_publishing_permission</a>(owner);
// Disallow incompatible upgrade mode. Governance can decide later <b>if</b> this should be reconsidered.
<b>assert</b>!(
pack.upgrade_policy.policy &gt; <a href="code.md#0x1_code_upgrade_policy_arbitrary">upgrade_policy_arbitrary</a>().policy,
Expand Down Expand Up @@ -679,6 +774,7 @@ package.


<pre><code><b>public</b> <b>fun</b> <a href="code.md#0x1_code_freeze_code_object">freeze_code_object</a>(publisher: &<a href="../../aptos-stdlib/../move-stdlib/doc/signer.md#0x1_signer">signer</a>, code_object: Object&lt;<a href="code.md#0x1_code_PackageRegistry">PackageRegistry</a>&gt;) <b>acquires</b> <a href="code.md#0x1_code_PackageRegistry">PackageRegistry</a> {
<a href="code.md#0x1_code_check_code_publishing_permission">check_code_publishing_permission</a>(publisher);
<b>let</b> code_object_addr = <a href="object.md#0x1_object_object_address">object::object_address</a>(&code_object);
<b>assert</b>!(<b>exists</b>&lt;<a href="code.md#0x1_code_PackageRegistry">PackageRegistry</a>&gt;(code_object_addr), <a href="../../aptos-stdlib/../move-stdlib/doc/error.md#0x1_error_not_found">error::not_found</a>(<a href="code.md#0x1_code_ECODE_OBJECT_DOES_NOT_EXIST">ECODE_OBJECT_DOES_NOT_EXIST</a>));
<b>assert</b>!(
Expand Down Expand Up @@ -1073,7 +1169,7 @@ Native function to initiate module loading, including a list of allowed dependen


<pre><code><b>pragma</b> verify = <b>true</b>;
<b>pragma</b> aborts_if_is_strict;
<b>pragma</b> aborts_if_is_partial;
</code></pre>


Expand Down Expand Up @@ -1253,4 +1349,17 @@ Native function to initiate module loading, including a list of allowed dependen
</code></pre>




<a id="0x1_code_AbortsIfPermissionedSigner"></a>


<pre><code><b>schema</b> <a href="code.md#0x1_code_AbortsIfPermissionedSigner">AbortsIfPermissionedSigner</a> {
s: <a href="../../aptos-stdlib/../move-stdlib/doc/signer.md#0x1_signer">signer</a>;
<b>let</b> perm = <a href="code.md#0x1_code_CodePublishingPermission">CodePublishingPermission</a> {};
<b>aborts_if</b> !<a href="permissioned_signer.md#0x1_permissioned_signer_spec_check_permission_exists">permissioned_signer::spec_check_permission_exists</a>(s, perm);
}
</code></pre>


[move-book]: https://aptos.dev/move/book/SUMMARY
10 changes: 10 additions & 0 deletions aptos-move/framework/aptos-framework/doc/create_signer.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,16 @@ Convert address to singer and return.
<pre><code><b>pragma</b> opaque;
<b>aborts_if</b> [abstract] <b>false</b>;
<b>ensures</b> [abstract] <a href="../../aptos-stdlib/../move-stdlib/doc/signer.md#0x1_signer_address_of">signer::address_of</a>(result) == addr;
<b>ensures</b> [abstract] result == <a href="create_signer.md#0x1_create_signer_spec_create_signer">spec_create_signer</a>(addr);
</code></pre>




<a id="0x1_create_signer_spec_create_signer"></a>


<pre><code><b>fun</b> <a href="create_signer.md#0x1_create_signer_spec_create_signer">spec_create_signer</a>(addr: <b>address</b>): <a href="../../aptos-stdlib/../move-stdlib/doc/signer.md#0x1_signer">signer</a>;
</code></pre>


Expand Down
Loading
Loading