Skip to content

Commit

Permalink
Create benchmark
Browse files Browse the repository at this point in the history
  • Loading branch information
runtian-zhou committed Jan 13, 2025
1 parent b4f375d commit afcf6ee
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 1 deletion.
2 changes: 2 additions & 0 deletions aptos-move/e2e-benchmark/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,8 @@ fn main() {
repeats: 100,
use_simple_map: false,
},
EntryPoints::APTPermissionedTransfer,
EntryPoints::APTTransfer,
];

let mut failures = Vec::new();
Expand Down
6 changes: 6 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,
PermissionedTransfer,
APTTransfer,
}

impl TransactionTypeArg {
Expand Down Expand Up @@ -351,6 +353,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),
}
}

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 @@ -222,6 +222,8 @@ pub enum EntryPoints {
/// there to slow down deserialization & verification, effectively making it more expensive to
/// load it into code cache.
SimpleScript,
APTPermissionedTransfer,
APTTransfer,
}

impl EntryPointTrait for EntryPoints {
Expand Down Expand Up @@ -274,7 +276,9 @@ impl EntryPointTrait for EntryPoints {
| EntryPoints::ResourceGroupsSenderWriteTag { .. }
| EntryPoints::ResourceGroupsSenderMultiChange { .. }
| EntryPoints::CoinInitAndMint
| EntryPoints::FungibleAssetMint => "framework_usecases",
| EntryPoints::FungibleAssetMint
| EntryPoints::APTPermissionedTransfer
| EntryPoints::APTTransfer => "framework_usecases",
EntryPoints::TokenV2AmbassadorMint { .. } | EntryPoints::TokenV2AmbassadorBurn => {
"ambassador_token"
},
Expand Down Expand Up @@ -353,6 +357,9 @@ impl EntryPointTrait for EntryPoints {
EntryPoints::IncGlobalMilestoneAggV2 { .. }
| EntryPoints::CreateGlobalMilestoneAggV2 { .. } => "counter_with_milestone",
EntryPoints::DeserializeU256 => "bcs_stream",
EntryPoints::APTPermissionedTransfer | EntryPoints::APTTransfer => {
"permissioned_transfer"
},
}
}

Expand Down Expand Up @@ -759,6 +766,20 @@ impl EntryPointTrait for EntryPoints {
],
)
},
EntryPoints::APTPermissionedTransfer => 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::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(),
])
},
}
}

Expand Down Expand Up @@ -877,6 +898,9 @@ impl EntryPointTrait for EntryPoints {
EntryPoints::DeserializeU256 => AutomaticArgs::None,
EntryPoints::IncGlobalMilestoneAggV2 { .. } => AutomaticArgs::None,
EntryPoints::CreateGlobalMilestoneAggV2 { .. } => AutomaticArgs::Signer,
EntryPoints::APTPermissionedTransfer | EntryPoints::APTTransfer => {
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 afcf6ee

Please sign in to comment.