Skip to content

Commit

Permalink
Create benchmark (aptos-labs#14916)
Browse files Browse the repository at this point in the history
  • Loading branch information
runtian-zhou authored Jan 15, 2025
1 parent c86a84f commit c7452c7
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 1 deletion.
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);
}

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

0 comments on commit c7452c7

Please sign in to comment.