From 16346c73b378accf6d33ba3436325e1c07577eca Mon Sep 17 00:00:00 2001 From: runtianz Date: Fri, 25 Oct 2024 12:49:31 -0700 Subject: [PATCH] add arg --- .../sources/aptos_governance.move | 4 +- .../aptos-framework/sources/code.move | 6 +- .../sources/delegation_pool.move | 58 ++++++++++++------- .../sources/object_code_deployment.move | 4 +- .../aptos-framework/sources/stake.move | 34 +++++------ .../sources/staking_proxy.move | 14 ++--- .../aptos-framework/sources/vesting.move | 8 ++- .../aptos-framework/sources/voting.move | 4 +- crates/transaction-generator-lib/src/args.rs | 6 ++ .../src/publishing/module_simple.rs | 22 +++---- 10 files changed, 92 insertions(+), 68 deletions(-) diff --git a/aptos-move/framework/aptos-framework/sources/aptos_governance.move b/aptos-move/framework/aptos-framework/sources/aptos_governance.move index bf325e9df2cc66..eb30287d99561b 100644 --- a/aptos-move/framework/aptos-framework/sources/aptos_governance.move +++ b/aptos-move/framework/aptos-framework/sources/aptos_governance.move @@ -172,7 +172,7 @@ module aptos_framework::aptos_governance { struct GovernancePermission has copy, drop, store {} /// Permissions - inline fun check_signer_permission(s: &signer) { + inline fun check_governance_permission(s: &signer) { assert!( permissioned_signer::check_permission_exists(s, GovernancePermission {}), error::permission_denied(ENO_GOVERNANCE_PERMISSION), @@ -394,7 +394,7 @@ module aptos_framework::aptos_governance { metadata_hash: vector, is_multi_step_proposal: bool, ): u64 acquires GovernanceConfig, GovernanceEvents { - check_signer_permission(proposer); + check_governance_permission(proposer); let proposer_address = signer::address_of(proposer); assert!( stake::get_delegated_voter(stake_pool) == proposer_address, diff --git a/aptos-move/framework/aptos-framework/sources/code.move b/aptos-move/framework/aptos-framework/sources/code.move index 1c112eb1dd3946..56a0b13d0056c0 100644 --- a/aptos-move/framework/aptos-framework/sources/code.move +++ b/aptos-move/framework/aptos-framework/sources/code.move @@ -114,7 +114,7 @@ module aptos_framework::code { struct CodePublishingPermission has copy, drop, store {} /// Permissions - public(friend) fun check_signer_permission(s: &signer) { + public(friend) fun check_code_publishing_permission(s: &signer) { assert!( permissioned_signer::check_permission_exists(s, CodePublishingPermission {}), error::permission_denied(ENO_CODE_PERMISSION), @@ -166,7 +166,7 @@ module aptos_framework::code { /// Publishes a package at the given signer's address. The caller must provide package metadata describing the /// package. public fun publish_package(owner: &signer, pack: PackageMetadata, code: vector>) acquires PackageRegistry { - check_signer_permission(owner); + check_code_publishing_permission(owner); // Disallow incompatible upgrade mode. Governance can decide later if this should be reconsidered. assert!( pack.upgrade_policy.policy > upgrade_policy_arbitrary().policy, @@ -228,7 +228,7 @@ module aptos_framework::code { } public fun freeze_code_object(publisher: &signer, code_object: Object) acquires PackageRegistry { - check_signer_permission(publisher); + check_code_publishing_permission(publisher); let code_object_addr = object::object_address(&code_object); assert!(exists(code_object_addr), error::not_found(ECODE_OBJECT_DOES_NOT_EXIST)); assert!( diff --git a/aptos-move/framework/aptos-framework/sources/delegation_pool.move b/aptos-move/framework/aptos-framework/sources/delegation_pool.move index 77de6760492a66..aba1fea5eb4bea 100644 --- a/aptos-move/framework/aptos-framework/sources/delegation_pool.move +++ b/aptos-move/framework/aptos-framework/sources/delegation_pool.move @@ -350,7 +350,10 @@ module aptos_framework::delegation_pool { allowlist: SmartTable, } - struct DelegationPermission has copy, drop, store {} + enum DelegationPermission has copy, drop, store { + DelegationPoolManagementPermission, + StakeManagementPermission, + } #[event] struct AddStake has drop, store { @@ -839,15 +842,26 @@ module aptos_framework::delegation_pool { } /// Permissions - inline fun check_signer_permission(s: &signer) { + inline fun check_delegation_pool_management_permission(s: &signer) { + assert!( + permissioned_signer::check_permission_exists(s, DelegationPermission::DelegationPoolManagementPermission {}), + error::permission_denied(ENO_DELEGATION_PERMISSION), + ); + } + + public fun grant_delegation_pool_management_permission(master: &signer, permissioned_signer: &signer) { + permissioned_signer::authorize_unlimited(master, permissioned_signer, DelegationPermission::DelegationPoolManagementPermission {}) + } + + inline fun check_stake_management_permission(s: &signer) { assert!( - permissioned_signer::check_permission_exists(s, DelegationPermission {}), + permissioned_signer::check_permission_exists(s, DelegationPermission::StakeManagementPermission {}), error::permission_denied(ENO_DELEGATION_PERMISSION), ); } - public fun grant_permission(master: &signer, permissioned_signer: &signer) { - permissioned_signer::authorize_unlimited(master, permissioned_signer, DelegationPermission {}) + public fun grant_stake_management_permission(master: &signer, permissioned_signer: &signer) { + permissioned_signer::authorize_unlimited(master, permissioned_signer, DelegationPermission::StakeManagementPermission {}) } /// Initialize a delegation pool of custom fixed `operator_commission_percentage`. @@ -859,7 +873,7 @@ module aptos_framework::delegation_pool { operator_commission_percentage: u64, delegation_pool_creation_seed: vector, ) acquires DelegationPool, GovernanceRecords, BeneficiaryForOperator, NextCommissionPercentage { - check_signer_permission(owner); + check_delegation_pool_management_permission(owner); assert!(features::delegation_pools_enabled(), error::invalid_state(EDELEGATION_POOLS_DISABLED)); let owner_address = signer::address_of(owner); assert!(!owner_cap_exists(owner_address), error::already_exists(EOWNER_CAP_ALREADY_EXISTS)); @@ -960,7 +974,7 @@ module aptos_framework::delegation_pool { voting_power: u64, should_pass: bool ) acquires DelegationPool, GovernanceRecords, BeneficiaryForOperator, NextCommissionPercentage { - check_signer_permission(voter); + check_stake_management_permission(voter); assert_partial_governance_voting_enabled(pool_address); // synchronize delegation and stake pools before any user operation. synchronize_delegation_pool(pool_address); @@ -1020,7 +1034,7 @@ module aptos_framework::delegation_pool { metadata_hash: vector, is_multi_step_proposal: bool, ) acquires DelegationPool, GovernanceRecords, BeneficiaryForOperator, NextCommissionPercentage { - check_signer_permission(voter); + check_stake_management_permission(voter); assert_partial_governance_voting_enabled(pool_address); // synchronize delegation and stake pools before any user operation @@ -1313,7 +1327,7 @@ module aptos_framework::delegation_pool { owner: &signer, new_operator: address ) acquires DelegationPoolOwnership, DelegationPool, GovernanceRecords, BeneficiaryForOperator, NextCommissionPercentage { - check_signer_permission(owner); + check_delegation_pool_management_permission(owner); let pool_address = get_owned_pool_address(signer::address_of(owner)); // synchronize delegation and stake pools before any user operation // ensure the old operator is paid its uncommitted commission rewards @@ -1329,7 +1343,7 @@ module aptos_framework::delegation_pool { operator: &signer, new_beneficiary: address ) acquires BeneficiaryForOperator { - check_signer_permission(operator); + check_stake_management_permission(operator); assert!(features::operator_beneficiary_change_enabled(), std::error::invalid_state( EOPERATOR_BENEFICIARY_CHANGE_NOT_SUPPORTED )); @@ -1355,7 +1369,7 @@ module aptos_framework::delegation_pool { owner: &signer, new_commission_percentage: u64 ) acquires DelegationPoolOwnership, DelegationPool, GovernanceRecords, BeneficiaryForOperator, NextCommissionPercentage { - check_signer_permission(owner); + check_delegation_pool_management_permission(owner); assert!(features::commission_change_delegation_pool_enabled(), error::invalid_state( ECOMMISSION_RATE_CHANGE_NOT_SUPPORTED )); @@ -1401,7 +1415,7 @@ module aptos_framework::delegation_pool { owner: &signer, new_voter: address ) acquires DelegationPoolOwnership, DelegationPool, GovernanceRecords, BeneficiaryForOperator, NextCommissionPercentage { - check_signer_permission(owner); + check_delegation_pool_management_permission(owner); // No one can change delegated_voter once the partial governance voting feature is enabled. assert!( !features::delegation_pool_partial_governance_voting_enabled(), @@ -1420,7 +1434,7 @@ module aptos_framework::delegation_pool { pool_address: address, new_voter: address ) acquires DelegationPool, GovernanceRecords, BeneficiaryForOperator, NextCommissionPercentage { - check_signer_permission(delegator); + check_stake_management_permission(delegator); assert_partial_governance_voting_enabled(pool_address); // synchronize delegation and stake pools before any user operation @@ -1478,7 +1492,7 @@ module aptos_framework::delegation_pool { public entry fun enable_delegators_allowlisting( owner: &signer, ) acquires DelegationPoolOwnership, DelegationPool { - check_signer_permission(owner); + check_delegation_pool_management_permission(owner); assert!( features::delegation_pool_allowlisting_enabled(), error::invalid_state(EDELEGATORS_ALLOWLISTING_NOT_SUPPORTED) @@ -1497,7 +1511,7 @@ module aptos_framework::delegation_pool { public entry fun disable_delegators_allowlisting( owner: &signer, ) acquires DelegationPoolOwnership, DelegationPoolAllowlisting { - check_signer_permission(owner); + check_delegation_pool_management_permission(owner); let pool_address = get_owned_pool_address(signer::address_of(owner)); assert_allowlisting_enabled(pool_address); @@ -1513,7 +1527,7 @@ module aptos_framework::delegation_pool { owner: &signer, delegator_address: address, ) acquires DelegationPoolOwnership, DelegationPoolAllowlisting { - check_signer_permission(owner); + check_delegation_pool_management_permission(owner); let pool_address = get_owned_pool_address(signer::address_of(owner)); assert_allowlisting_enabled(pool_address); @@ -1529,7 +1543,7 @@ module aptos_framework::delegation_pool { owner: &signer, delegator_address: address, ) acquires DelegationPoolOwnership, DelegationPoolAllowlisting { - check_signer_permission(owner); + check_delegation_pool_management_permission(owner); let pool_address = get_owned_pool_address(signer::address_of(owner)); assert_allowlisting_enabled(pool_address); @@ -1545,7 +1559,7 @@ module aptos_framework::delegation_pool { owner: &signer, delegator_address: address, ) acquires DelegationPoolOwnership, DelegationPool, GovernanceRecords, BeneficiaryForOperator, NextCommissionPercentage, DelegationPoolAllowlisting { - check_signer_permission(owner); + check_delegation_pool_management_permission(owner); let pool_address = get_owned_pool_address(signer::address_of(owner)); assert_allowlisting_enabled(pool_address); assert!( @@ -1570,7 +1584,7 @@ module aptos_framework::delegation_pool { pool_address: address, amount: u64 ) acquires DelegationPool, GovernanceRecords, BeneficiaryForOperator, NextCommissionPercentage, DelegationPoolAllowlisting { - check_signer_permission(delegator); + check_stake_management_permission(delegator); // short-circuit if amount to add is 0 so no event is emitted if (amount == 0) { return }; @@ -1628,7 +1642,7 @@ module aptos_framework::delegation_pool { pool_address: address, amount: u64 ) acquires DelegationPool, GovernanceRecords, BeneficiaryForOperator, NextCommissionPercentage { - check_signer_permission(delegator); + check_stake_management_permission(delegator); // short-circuit if amount to unlock is 0 so no event is emitted if (amount == 0) { return }; @@ -1690,7 +1704,7 @@ module aptos_framework::delegation_pool { pool_address: address, amount: u64 ) acquires DelegationPool, GovernanceRecords, BeneficiaryForOperator, NextCommissionPercentage, DelegationPoolAllowlisting { - check_signer_permission(delegator); + check_stake_management_permission(delegator); // short-circuit if amount to reactivate is 0 so no event is emitted if (amount == 0) { return }; @@ -1741,7 +1755,7 @@ module aptos_framework::delegation_pool { pool_address: address, amount: u64 ) acquires DelegationPool, GovernanceRecords, BeneficiaryForOperator, NextCommissionPercentage { - check_signer_permission(delegator); + check_stake_management_permission(delegator); assert!(amount > 0, error::invalid_argument(EWITHDRAW_ZERO_STAKE)); // synchronize delegation and stake pools before any user operation synchronize_delegation_pool(pool_address); diff --git a/aptos-move/framework/aptos-framework/sources/object_code_deployment.move b/aptos-move/framework/aptos-framework/sources/object_code_deployment.move index c6b8b31e193ac6..f611d1003573d6 100644 --- a/aptos-move/framework/aptos-framework/sources/object_code_deployment.move +++ b/aptos-move/framework/aptos-framework/sources/object_code_deployment.move @@ -86,7 +86,7 @@ module aptos_framework::object_code_deployment { metadata_serialized: vector, code: vector>, ) { - code::check_signer_permission(publisher); + code::check_code_publishing_permission(publisher); assert!( features::is_object_code_deployment_enabled(), error::unavailable(EOBJECT_CODE_DEPLOYMENT_NOT_SUPPORTED), @@ -123,7 +123,7 @@ module aptos_framework::object_code_deployment { code: vector>, code_object: Object, ) acquires ManagingRefs { - code::check_signer_permission(publisher); + code::check_code_publishing_permission(publisher); let publisher_address = signer::address_of(publisher); assert!( object::is_owner(code_object, publisher_address), diff --git a/aptos-move/framework/aptos-framework/sources/stake.move b/aptos-move/framework/aptos-framework/sources/stake.move index 7c91391da1b250..37c0fa0c1a43d4 100644 --- a/aptos-move/framework/aptos-framework/sources/stake.move +++ b/aptos-move/framework/aptos-framework/sources/stake.move @@ -350,7 +350,7 @@ module aptos_framework::stake { } /// Permissions - inline fun check_signer_permission(s: &signer) { + inline fun check_stake_permission(s: &signer) { assert!( permissioned_signer::check_permission_exists(s, StakeManagementPermission {}), error::permission_denied(ENO_STAKE_PERMISSION), @@ -554,7 +554,7 @@ module aptos_framework::stake { operator: address, voter: address, ) acquires AllowedValidators, OwnerCapability, StakePool, ValidatorSet { - check_signer_permission(owner); + check_stake_permission(owner); initialize_owner(owner); move_to(owner, ValidatorConfig { consensus_pubkey: vector::empty(), @@ -584,7 +584,7 @@ module aptos_framework::stake { network_addresses: vector, fullnode_addresses: vector, ) acquires AllowedValidators { - check_signer_permission(account); + check_stake_permission(account); // Checks the public key has a valid proof-of-possession to prevent rogue-key attacks. let pubkey_from_pop = &bls12381::public_key_from_bytes_with_pop( consensus_pubkey, @@ -602,7 +602,7 @@ module aptos_framework::stake { } fun initialize_owner(owner: &signer) acquires AllowedValidators { - check_signer_permission(owner); + check_stake_permission(owner); let owner_address = signer::address_of(owner); assert!(is_allowed(owner_address), error::not_found(EINELIGIBLE_VALIDATOR)); assert!(!stake_pool_exists(owner_address), error::already_exists(EALREADY_REGISTERED)); @@ -637,7 +637,7 @@ module aptos_framework::stake { /// Extract and return owner capability from the signing account. public fun extract_owner_cap(owner: &signer): OwnerCapability acquires OwnerCapability { - check_signer_permission(owner); + check_stake_permission(owner); let owner_address = signer::address_of(owner); assert_owner_cap_exists(owner_address); move_from(owner_address) @@ -646,7 +646,7 @@ module aptos_framework::stake { /// Deposit `owner_cap` into `account`. This requires `account` to not already have ownership of another /// staking pool. public fun deposit_owner_cap(owner: &signer, owner_cap: OwnerCapability) { - check_signer_permission(owner); + check_stake_permission(owner); assert!(!exists(signer::address_of(owner)), error::not_found(EOWNER_CAP_ALREADY_EXISTS)); move_to(owner, owner_cap); } @@ -658,7 +658,7 @@ module aptos_framework::stake { /// Allows an owner to change the operator of the stake pool. public entry fun set_operator(owner: &signer, new_operator: address) acquires OwnerCapability, StakePool { - check_signer_permission(owner); + check_stake_permission(owner); let owner_address = signer::address_of(owner); assert_owner_cap_exists(owner_address); let ownership_cap = borrow_global(owner_address); @@ -695,7 +695,7 @@ module aptos_framework::stake { /// Allows an owner to change the delegated voter of the stake pool. public entry fun set_delegated_voter(owner: &signer, new_voter: address) acquires OwnerCapability, StakePool { - check_signer_permission(owner); + check_stake_permission(owner); let owner_address = signer::address_of(owner); assert_owner_cap_exists(owner_address); let ownership_cap = borrow_global(owner_address); @@ -712,7 +712,7 @@ module aptos_framework::stake { /// Add `amount` of coins from the `account` owning the StakePool. public entry fun add_stake(owner: &signer, amount: u64) acquires OwnerCapability, StakePool, ValidatorSet { - check_signer_permission(owner); + check_stake_permission(owner); let owner_address = signer::address_of(owner); assert_owner_cap_exists(owner_address); let ownership_cap = borrow_global(owner_address); @@ -774,7 +774,7 @@ module aptos_framework::stake { /// Move `amount` of coins from pending_inactive to active. public entry fun reactivate_stake(owner: &signer, amount: u64) acquires OwnerCapability, StakePool { - check_signer_permission(owner); + check_stake_permission(owner); assert_reconfig_not_in_progress(); let owner_address = signer::address_of(owner); assert_owner_cap_exists(owner_address); @@ -823,7 +823,7 @@ module aptos_framework::stake { new_consensus_pubkey: vector, proof_of_possession: vector, ) acquires StakePool, ValidatorConfig { - check_signer_permission(operator); + check_stake_permission(operator); assert_reconfig_not_in_progress(); assert_stake_pool_exists(pool_address); @@ -868,7 +868,7 @@ module aptos_framework::stake { new_network_addresses: vector, new_fullnode_addresses: vector, ) acquires StakePool, ValidatorConfig { - check_signer_permission(operator); + check_stake_permission(operator); assert_reconfig_not_in_progress(); assert_stake_pool_exists(pool_address); let stake_pool = borrow_global_mut(pool_address); @@ -906,7 +906,7 @@ module aptos_framework::stake { /// Similar to increase_lockup_with_cap but will use ownership capability from the signing account. public entry fun increase_lockup(owner: &signer) acquires OwnerCapability, StakePool { - check_signer_permission(owner); + check_stake_permission(owner); let owner_address = signer::address_of(owner); assert_owner_cap_exists(owner_address); let ownership_cap = borrow_global(owner_address); @@ -951,7 +951,7 @@ module aptos_framework::stake { operator: &signer, pool_address: address ) acquires StakePool, ValidatorConfig, ValidatorSet { - check_signer_permission(operator); + check_stake_permission(operator); assert!( staking_config::get_allow_validator_set_change(&staking_config::get()), error::invalid_argument(ENO_POST_GENESIS_VALIDATOR_SET_CHANGE_ALLOWED), @@ -1015,7 +1015,7 @@ module aptos_framework::stake { /// Similar to unlock_with_cap but will use ownership capability from the signing account. public entry fun unlock(owner: &signer, amount: u64) acquires OwnerCapability, StakePool { - check_signer_permission(owner); + check_stake_permission(owner); assert_reconfig_not_in_progress(); let owner_address = signer::address_of(owner); assert_owner_cap_exists(owner_address); @@ -1064,7 +1064,7 @@ module aptos_framework::stake { owner: &signer, withdraw_amount: u64 ) acquires OwnerCapability, StakePool, ValidatorSet { - check_signer_permission(owner); + check_stake_permission(owner); let owner_address = signer::address_of(owner); assert_owner_cap_exists(owner_address); let ownership_cap = borrow_global(owner_address); @@ -1124,7 +1124,7 @@ module aptos_framework::stake { operator: &signer, pool_address: address ) acquires StakePool, ValidatorSet { - check_signer_permission(operator); + check_stake_permission(operator); assert_reconfig_not_in_progress(); let config = staking_config::get(); assert!( diff --git a/aptos-move/framework/aptos-framework/sources/staking_proxy.move b/aptos-move/framework/aptos-framework/sources/staking_proxy.move index 47a8bfbd9ae9e9..76ffbd2182a638 100644 --- a/aptos-move/framework/aptos-framework/sources/staking_proxy.move +++ b/aptos-move/framework/aptos-framework/sources/staking_proxy.move @@ -14,7 +14,7 @@ module aptos_framework::staking_proxy { const ENO_STAKE_PERMISSION: u64 = 28; /// Permissions - inline fun check_signer_permission(s: &signer) { + inline fun check_stake_proxy_permission(s: &signer) { assert!( permissioned_signer::check_permission_exists(s, StakeProxyPermission {}), error::permission_denied(ENO_STAKE_PERMISSION), @@ -39,7 +39,7 @@ module aptos_framework::staking_proxy { } public entry fun set_vesting_contract_operator(owner: &signer, old_operator: address, new_operator: address) { - check_signer_permission(owner); + check_stake_proxy_permission(owner); let owner_address = signer::address_of(owner); let vesting_contracts = &vesting::vesting_contracts(owner_address); vector::for_each_ref(vesting_contracts, |vesting_contract| { @@ -52,7 +52,7 @@ module aptos_framework::staking_proxy { } public entry fun set_staking_contract_operator(owner: &signer, old_operator: address, new_operator: address) { - check_signer_permission(owner); + check_stake_proxy_permission(owner); let owner_address = signer::address_of(owner); if (staking_contract::staking_contract_exists(owner_address, old_operator)) { let current_commission_percentage = staking_contract::commission_percentage(owner_address, old_operator); @@ -61,7 +61,7 @@ module aptos_framework::staking_proxy { } public entry fun set_stake_pool_operator(owner: &signer, new_operator: address) { - check_signer_permission(owner); + check_stake_proxy_permission(owner); let owner_address = signer::address_of(owner); if (stake::stake_pool_exists(owner_address)) { stake::set_operator(owner, new_operator); @@ -69,7 +69,7 @@ module aptos_framework::staking_proxy { } public entry fun set_vesting_contract_voter(owner: &signer, operator: address, new_voter: address) { - check_signer_permission(owner); + check_stake_proxy_permission(owner); let owner_address = signer::address_of(owner); let vesting_contracts = &vesting::vesting_contracts(owner_address); vector::for_each_ref(vesting_contracts, |vesting_contract| { @@ -81,7 +81,7 @@ module aptos_framework::staking_proxy { } public entry fun set_staking_contract_voter(owner: &signer, operator: address, new_voter: address) { - check_signer_permission(owner); + check_stake_proxy_permission(owner); let owner_address = signer::address_of(owner); if (staking_contract::staking_contract_exists(owner_address, operator)) { staking_contract::update_voter(owner, operator, new_voter); @@ -89,7 +89,7 @@ module aptos_framework::staking_proxy { } public entry fun set_stake_pool_voter(owner: &signer, new_voter: address) { - check_signer_permission(owner); + check_stake_proxy_permission(owner); if (stake::stake_pool_exists(signer::address_of(owner))) { stake::set_delegated_voter(owner, new_voter); }; diff --git a/aptos-move/framework/aptos-framework/sources/vesting.move b/aptos-move/framework/aptos-framework/sources/vesting.move index 0f24d99aefc318..718eb20654fc28 100644 --- a/aptos-move/framework/aptos-framework/sources/vesting.move +++ b/aptos-move/framework/aptos-framework/sources/vesting.move @@ -331,10 +331,11 @@ module aptos_framework::vesting { amount: u64, } + /// Permissions to mutate the vesting config for a given account. struct VestPermission has copy, drop, store {} /// Permissions - inline fun check_signer_permission(s: &signer) { + inline fun check_vest_permission(s: &signer) { assert!( permissioned_signer::check_permission_exists(s, VestPermission {}), error::permission_denied(ENO_VESTING_PERMISSION), @@ -553,6 +554,7 @@ module aptos_framework::vesting { // Optional seed used when creating the staking contract account. contract_creation_seed: vector, ): address acquires AdminStore { + check_vest_permission(admin); assert!( !system_addresses::is_reserved_address(withdrawal_address), error::invalid_argument(EINVALID_WITHDRAWAL_ADDRESS), @@ -1071,6 +1073,7 @@ module aptos_framework::vesting { contract_address: address, shareholder: address, ) acquires VestingAccountManagement, VestingContract { + check_vest_permission(account); let vesting_contract = borrow_global_mut(contract_address); let addr = signer::address_of(account); assert!( @@ -1150,6 +1153,7 @@ module aptos_framework::vesting { admin: &signer, contract_creation_seed: vector, ): (signer, SignerCapability) acquires AdminStore { + check_vest_permission(admin); let admin_store = borrow_global_mut(signer::address_of(admin)); let seed = bcs::to_bytes(&signer::address_of(admin)); vector::append(&mut seed, bcs::to_bytes(&admin_store.nonce)); @@ -1169,7 +1173,7 @@ module aptos_framework::vesting { } fun verify_admin(admin: &signer, vesting_contract: &VestingContract) { - check_signer_permission(admin); + check_vest_permission(admin); assert!(signer::address_of(admin) == vesting_contract.admin, error::unauthenticated(ENOT_ADMIN)); } diff --git a/aptos-move/framework/aptos-framework/sources/voting.move b/aptos-move/framework/aptos-framework/sources/voting.move index 651cd9691c0eed..8dd1b0cb2e9a52 100644 --- a/aptos-move/framework/aptos-framework/sources/voting.move +++ b/aptos-move/framework/aptos-framework/sources/voting.move @@ -194,7 +194,7 @@ module aptos_framework::voting { struct VotePermission has copy, drop, store {} /// Permissions - inline fun check_signer_permission(s: &signer) { + inline fun check_vote_permission(s: &signer) { assert!( permissioned_signer::check_permission_exists(s, VotePermission {}), error::permission_denied(ENO_VOTE_PERMISSION), @@ -207,7 +207,7 @@ module aptos_framework::voting { } public fun register(account: &signer) { - check_signer_permission(account); + check_vote_permission(account); let addr = signer::address_of(account); assert!(!exists>(addr), error::already_exists(EVOTING_FORUM_ALREADY_REGISTERED)); diff --git a/crates/transaction-generator-lib/src/args.rs b/crates/transaction-generator-lib/src/args.rs index fb0cc7779d4276..904fb1b1eeb75b 100644 --- a/crates/transaction-generator-lib/src/args.rs +++ b/crates/transaction-generator-lib/src/args.rs @@ -74,6 +74,8 @@ pub enum TransactionTypeArg { SmartTablePicture1MWith1KChangeExceedsLimit, DeserializeU256, SimpleScript, + PermissionedTransfer, + APTTransfer, } impl TransactionTypeArg { @@ -326,6 +328,10 @@ impl TransactionTypeArg { }, TransactionTypeArg::DeserializeU256 => call_custom_module(EntryPoints::DeserializeU256), TransactionTypeArg::SimpleScript => call_custom_module(EntryPoints::SimpleScript), + TransactionTypeArg::PermissionedTransfer => { + call_custom_module(EntryPoints::APTPermissionedTransfer) + }, + TransactionTypeArg::APTTransfer => call_custom_module(EntryPoints::APTTransfer), } } diff --git a/crates/transaction-generator-lib/src/publishing/module_simple.rs b/crates/transaction-generator-lib/src/publishing/module_simple.rs index f52e3d9f1afa85..a8875bb1fa81b9 100644 --- a/crates/transaction-generator-lib/src/publishing/module_simple.rs +++ b/crates/transaction-generator-lib/src/publishing/module_simple.rs @@ -396,9 +396,10 @@ impl EntryPoints { }, EntryPoints::IncGlobalMilestoneAggV2 { .. } | EntryPoints::CreateGlobalMilestoneAggV2 { .. } => "counter_with_milestone", - | EntryPoints::DeserializeU256 => "bcs_stream", - EntryPoints::APTPermissionedTransfer - | EntryPoints::APTTransfer => "permissioned_transfer", + EntryPoints::DeserializeU256 => "bcs_stream", + EntryPoints::APTPermissionedTransfer | EntryPoints::APTTransfer => { + "permissioned_transfer" + }, } } @@ -759,14 +760,12 @@ impl EntryPoints { bcs::to_bytes(&1u64).unwrap(), ], ), - EntryPoints::APTTransfer => get_payload( - module_id, - ident_str!("transfer").to_owned(), - vec![ + EntryPoints::APTTransfer => { + get_payload(module_id, ident_str!("transfer").to_owned(), vec![ bcs::to_bytes(&other.expect("Must provide other")).unwrap(), bcs::to_bytes(&1u64).unwrap(), - ], - ) + ]) + }, } } @@ -877,8 +876,9 @@ impl EntryPoints { EntryPoints::DeserializeU256 => AutomaticArgs::None, EntryPoints::IncGlobalMilestoneAggV2 { .. } => AutomaticArgs::None, EntryPoints::CreateGlobalMilestoneAggV2 { .. } => AutomaticArgs::Signer, - EntryPoints::APTPermissionedTransfer - | EntryPoints::APTTransfer => AutomaticArgs::Signer, + EntryPoints::APTPermissionedTransfer | EntryPoints::APTTransfer => { + AutomaticArgs::Signer + }, } } }