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

Create benchmark #14916

Merged
merged 1 commit into from
Jan 15, 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
8 changes: 8 additions & 0 deletions crates/transaction-workloads-lib/src/args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ pub enum TransactionTypeArg {
SmartTablePicture1MWith1KChangeExceedsLimit,
DeserializeU256,
SimpleScript,
APTTransferWithPermissionedSigner,
APTTransferWithMasterSigner,
}

impl TransactionTypeArg {
Expand Down Expand Up @@ -351,6 +353,12 @@ impl TransactionTypeArg {
},
TransactionTypeArg::DeserializeU256 => call_custom_module(EntryPoints::DeserializeU256),
TransactionTypeArg::SimpleScript => call_custom_module(EntryPoints::SimpleScript),
TransactionTypeArg::APTTransferWithPermissionedSigner => {
call_custom_module(EntryPoints::APTTransferWithPermissionedSigner)
},
TransactionTypeArg::APTTransferWithMasterSigner => {
call_custom_module(EntryPoints::APTTransferWithMasterSigner)
},
}
}

Expand Down
26 changes: 25 additions & 1 deletion crates/transaction-workloads-lib/src/move_workloads.rs
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,10 @@ pub enum EntryPoints {
/// there to slow down deserialization & verification, effectively making it more expensive to
/// load it into code cache.
SimpleScript,
/// Set up an APT transfer permission and transfering APT by using that permissioned signer.
APTTransferWithPermissionedSigner,
/// Transfer APT using vanilla master signer to compare the performance.
APTTransferWithMasterSigner,
}

impl EntryPointTrait for EntryPoints {
Expand Down Expand Up @@ -284,7 +288,9 @@ impl EntryPointTrait for EntryPoints {
| EntryPoints::ResourceGroupsSenderWriteTag { .. }
| EntryPoints::ResourceGroupsSenderMultiChange { .. }
| EntryPoints::CoinInitAndMint
| EntryPoints::FungibleAssetMint => "framework_usecases",
| EntryPoints::FungibleAssetMint
| EntryPoints::APTTransferWithPermissionedSigner
| EntryPoints::APTTransferWithMasterSigner => "framework_usecases",
EntryPoints::TokenV2AmbassadorMint { .. } | EntryPoints::TokenV2AmbassadorBurn => {
"ambassador_token"
},
Expand Down Expand Up @@ -363,6 +369,8 @@ impl EntryPointTrait for EntryPoints {
EntryPoints::IncGlobalMilestoneAggV2 { .. }
| EntryPoints::CreateGlobalMilestoneAggV2 { .. } => "counter_with_milestone",
EntryPoints::DeserializeU256 => "bcs_stream",
EntryPoints::APTTransferWithPermissionedSigner
| EntryPoints::APTTransferWithMasterSigner => "permissioned_transfer",
}
}

Expand Down Expand Up @@ -781,6 +789,20 @@ impl EntryPointTrait for EntryPoints {
],
)
},
EntryPoints::APTTransferWithPermissionedSigner => get_payload(
module_id,
ident_str!("transfer_permissioned").to_owned(),
vec![
bcs::to_bytes(&other.expect("Must provide other")).unwrap(),
bcs::to_bytes(&1u64).unwrap(),
],
),
EntryPoints::APTTransferWithMasterSigner => {
get_payload(module_id, ident_str!("transfer").to_owned(), vec![
bcs::to_bytes(&other.expect("Must provide other")).unwrap(),
bcs::to_bytes(&1u64).unwrap(),
])
},
}
}

Expand Down Expand Up @@ -899,6 +921,8 @@ impl EntryPointTrait for EntryPoints {
EntryPoints::DeserializeU256 => AutomaticArgs::None,
EntryPoints::IncGlobalMilestoneAggV2 { .. } => AutomaticArgs::None,
EntryPoints::CreateGlobalMilestoneAggV2 { .. } => AutomaticArgs::Signer,
EntryPoints::APTTransferWithPermissionedSigner
| EntryPoints::APTTransferWithMasterSigner => AutomaticArgs::Signer,
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@

module 0xABCD::permissioned_transfer {
use aptos_framework::aptos_account;
use aptos_framework::permissioned_signer;
use aptos_framework::primary_fungible_store;

public entry fun transfer_permissioned(
source: &signer, to: address, amount: u64
) {
let handle = permissioned_signer::create_permissioned_handle(source);
let permissioned_signer = permissioned_signer::signer_from_permissioned_handle(&handle);

primary_fungible_store::grant_apt_permission(source, &permissioned_signer, amount);
aptos_account::transfer(&permissioned_signer, to, amount);

permissioned_signer::destroy_permissioned_handle(handle);
Comment on lines +13 to +16
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The permissioned_signer retains its APT transfer permissions after the transfer completes. To maintain proper permission hygiene, call primary_fungible_store::revoke_apt_permission(source, &permissioned_signer) before destroying the handle. This ensures no permissions persist beyond their intended use.

Spotted by Graphite Reviewer

Is this helpful? React 👍 or 👎 to let us know.

}
Comment on lines +7 to +17
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The transfer_permissioned function needs error handling around grant_apt_permission to prevent resource leaks. If permission granting fails, the handle created by create_permissioned_handle will not be properly cleaned up. Consider wrapping the permission and transfer operations in a let-else block to ensure destroy_permissioned_handle is called in both success and failure paths.

Spotted by Graphite Reviewer

Is this helpful? React 👍 or 👎 to let us know.


public entry fun transfer(
source: &signer, to: address, amount: u64
) {
aptos_account::transfer(source, to, amount);
}
}
Loading