Skip to content

Commit

Permalink
Create benchmark
Browse files Browse the repository at this point in the history
  • Loading branch information
runtian-zhou committed Dec 17, 2024
1 parent 6db859a commit 60ce91a
Show file tree
Hide file tree
Showing 5 changed files with 111 additions and 19 deletions.
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 @@ -202,6 +202,8 @@ fn main() {
EntryPoints::IncGlobalMilestoneAggV2 { milestone_every: 1 },
EntryPoints::IncGlobalMilestoneAggV2 { milestone_every: 2 },
EntryPoints::EmitEvents { count: 1000 },
EntryPoints::APTPermissionedTransfer,
EntryPoints::APTTransfer,
];

let mut failures = Vec::new();
Expand Down
6 changes: 6 additions & 0 deletions crates/transaction-generator-lib/src/args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ pub enum TransactionTypeArg {
SmartTablePicture1MWith1KChangeExceedsLimit,
DeserializeU256,
SimpleScript,
PermissionedTransfer,
APTTransfer,
}

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

Expand Down
26 changes: 25 additions & 1 deletion crates/transaction-generator-lib/src/publishing/module_simple.rs
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,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 EntryPoints {
Expand Down Expand Up @@ -318,7 +320,9 @@ impl 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 @@ -393,6 +397,9 @@ impl EntryPoints {
EntryPoints::IncGlobalMilestoneAggV2 { .. }
| EntryPoints::CreateGlobalMilestoneAggV2 { .. } => "counter_with_milestone",
EntryPoints::DeserializeU256 => "bcs_stream",
EntryPoints::APTPermissionedTransfer | EntryPoints::APTTransfer => {
"permissioned_transfer"
},
}
}

Expand Down Expand Up @@ -745,6 +752,20 @@ impl 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 @@ -855,6 +876,9 @@ impl EntryPoints {
EntryPoints::DeserializeU256 => AutomaticArgs::None,
EntryPoints::IncGlobalMilestoneAggV2 { .. } => AutomaticArgs::None,
EntryPoints::CreateGlobalMilestoneAggV2 { .. } => AutomaticArgs::Signer,
EntryPoints::APTPermissionedTransfer | EntryPoints::APTTransfer => {
AutomaticArgs::Signer
},
}
}
}
Expand Down
72 changes: 54 additions & 18 deletions crates/transaction-generator-lib/src/publishing/raw_module_data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1000,11 +1000,11 @@ pub static MODULES_SIMPLE: Lazy<Vec<Vec<u8>>> = Lazy::new(|| { vec![
pub static PACKAGE_FRAMEWORK_USECASES_METADATA: Lazy<Vec<u8>> = Lazy::new(|| {
vec![
17, 70, 114, 97, 109, 101, 119, 111, 114, 107, 85, 115, 101, 99, 97, 115, 101, 115,
1, 0, 0, 0, 0, 0, 0, 0, 0, 64, 55, 49, 50, 55, 50, 50, 66, 65,
65, 50, 67, 49, 53, 66, 70, 54, 65, 70, 53, 70, 55, 52, 65, 67, 69, 56,
51, 68, 53, 66, 66, 54, 66, 67, 56, 56, 49, 69, 66, 67, 68, 66, 66, 57,
52, 48, 49, 54, 66, 66, 53, 66, 67, 48, 49, 51, 56, 49, 49, 50, 51, 53,
66, 50, 215, 1, 31, 139, 8, 0, 0, 0, 0, 0, 2, 255, 165, 144, 187, 142,
1, 0, 0, 0, 0, 0, 0, 0, 0, 64, 56, 53, 57, 65, 70, 57, 66, 66,
48, 49, 54, 54, 70, 66, 52, 49, 54, 50, 67, 52, 67, 68, 57, 57, 70, 52,
70, 55, 57, 48, 51, 55, 68, 57, 49, 54, 55, 54, 55, 51, 68, 49, 66, 54,
70, 70, 49, 51, 66, 70, 55, 56, 52, 67, 55, 49, 65, 50, 68, 49, 48, 53,
48, 66, 215, 1, 31, 139, 8, 0, 0, 0, 0, 0, 2, 255, 165, 144, 187, 142,
194, 64, 12, 69, 251, 249, 10, 107, 182, 38, 236, 15, 108, 193, 238, 138, 150, 6,
170, 8, 33, 51, 49, 33, 100, 176, 163, 241, 240, 144, 16, 255, 78, 44, 30, 130,
22, 100, 23, 215, 246, 189, 167, 112, 217, 97, 104, 177, 166, 185, 99, 220, 18, 252,
Expand All @@ -1016,26 +1016,27 @@ pub static PACKAGE_FRAMEWORK_USECASES_METADATA: Lazy<Vec<u8>> = Lazy::new(|| {
134, 107, 160, 99, 88, 35, 215, 38, 101, 5, 65, 88, 51, 114, 6, 172, 170, 68,
170, 96, 20, 5, 236, 5, 197, 88, 184, 242, 182, 183, 231, 117, 187, 101, 108, 116,
77, 105, 113, 55, 219, 163, 143, 163, 223, 191, 127, 239, 46, 112, 10, 188, 112, 161,
1, 0, 0, 6, 18, 97, 103, 103, 114, 101, 103, 97, 116, 111, 114, 95, 101, 120,
1, 0, 0, 7, 18, 97, 103, 103, 114, 101, 103, 97, 116, 111, 114, 95, 101, 120,
97, 109, 112, 108, 101, 0, 0, 0, 12, 99, 111, 105, 110, 95, 101, 120, 97, 109,
112, 108, 101, 0, 0, 0, 22, 102, 117, 110, 103, 105, 98, 108, 101, 95, 97, 115,
115, 101, 116, 95, 101, 120, 97, 109, 112, 108, 101, 0, 0, 0, 7, 111, 98, 106,
101, 99, 116, 115, 0, 0, 0, 23, 114, 101, 115, 111, 117, 114, 99, 101, 95, 103,
114, 111, 117, 112, 115, 95, 101, 120, 97, 109, 112, 108, 101, 0, 0, 0, 8, 116,
111, 107, 101, 110, 95, 118, 49, 0, 0, 0, 5, 0, 0, 0, 0, 0, 0, 0,
101, 99, 116, 115, 0, 0, 0, 21, 112, 101, 114, 109, 105, 115, 115, 105, 111, 110,
101, 100, 95, 116, 114, 97, 110, 115, 102, 101, 114, 0, 0, 0, 23, 114, 101, 115,
111, 117, 114, 99, 101, 95, 103, 114, 111, 117, 112, 115, 95, 101, 120, 97, 109, 112,
108, 101, 0, 0, 0, 8, 116, 111, 107, 101, 110, 95, 118, 49, 0, 0, 0, 5,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 1, 14, 65, 112, 116, 111, 115, 70, 114, 97, 109, 101,
119, 111, 114, 107, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1,
11, 65, 112, 116, 111, 115, 83, 116, 100, 108, 105, 98, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 14, 65, 112, 116,
111, 115, 70, 114, 97, 109, 101, 119, 111, 114, 107, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 1, 10, 77, 111, 118, 101, 83, 116, 100, 108, 105,
0, 0, 0, 0, 0, 0, 1, 11, 65, 112, 116, 111, 115, 83, 116, 100, 108, 105,
98, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 10, 65, 112,
116, 111, 115, 84, 111, 107, 101, 110, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 10, 77, 111,
118, 101, 83, 116, 100, 108, 105, 98, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 3, 10, 65, 112, 116, 111, 115, 84, 111, 107, 101, 110, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 4, 17, 65, 112, 116, 111, 115, 84, 111, 107, 101, 110, 79, 98, 106,
101, 99, 116, 115, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 17, 65, 112, 116, 111, 115, 84,
111, 107, 101, 110, 79, 98, 106, 101, 99, 116, 115, 0,
]
});

Expand Down Expand Up @@ -1293,6 +1294,40 @@ pub static MODULE_FRAMEWORK_USECASES_OBJECTS: Lazy<Vec<u8>> = Lazy::new(|| {
]
});

#[rustfmt::skip]
pub static MODULE_FRAMEWORK_USECASES_PERMISSIONED_TRANSFER: Lazy<Vec<u8>> = Lazy::new(|| {
vec![
161, 28, 235, 11, 7, 0, 0, 10, 8, 1, 0, 8, 2, 8, 4, 3, 12, 42,
5, 54, 30, 7, 84, 222, 1, 8, 178, 2, 64, 16, 242, 2, 31, 12, 145, 3,
58, 0, 0, 1, 2, 1, 4, 1, 8, 2, 6, 0, 0, 0, 1, 0, 1, 0,
1, 1, 1, 0, 1, 0, 1, 0, 3, 0, 1, 0, 1, 2, 5, 2, 3, 0,
1, 2, 7, 4, 5, 0, 1, 3, 9, 6, 1, 0, 1, 2, 10, 3, 1, 0,
1, 3, 6, 12, 5, 3, 0, 1, 6, 12, 1, 8, 0, 1, 6, 8, 0, 1,
12, 3, 6, 12, 6, 12, 3, 3, 8, 0, 12, 6, 12, 21, 112, 101, 114, 109,
105, 115, 115, 105, 111, 110, 101, 100, 95, 116, 114, 97, 110, 115, 102, 101, 114, 8,
116, 114, 97, 110, 115, 102, 101, 114, 13, 97, 112, 116, 111, 115, 95, 97, 99, 99,
111, 117, 110, 116, 21, 116, 114, 97, 110, 115, 102, 101, 114, 95, 112, 101, 114, 109,
105, 115, 115, 105, 111, 110, 101, 100, 19, 112, 101, 114, 109, 105, 115, 115, 105, 111,
110, 101, 100, 95, 115, 105, 103, 110, 101, 114, 26, 99, 114, 101, 97, 116, 101, 95,
112, 101, 114, 109, 105, 115, 115, 105, 111, 110, 101, 100, 95, 104, 97, 110, 100, 108,
101, 18, 80, 101, 114, 109, 105, 115, 115, 105, 111, 110, 101, 100, 72, 97, 110, 100,
108, 101, 24, 115, 105, 103, 110, 101, 114, 95, 102, 114, 111, 109, 95, 112, 101, 114,
109, 105, 115, 115, 105, 111, 110, 101, 100, 14, 102, 117, 110, 103, 105, 98, 108, 101,
95, 97, 115, 115, 101, 116, 20, 103, 114, 97, 110, 116, 95, 97, 112, 116, 95, 112,
101, 114, 109, 105, 115, 115, 105, 111, 110, 27, 100, 101, 115, 116, 114, 111, 121, 95,
112, 101, 114, 109, 105, 115, 115, 105, 111, 110, 101, 100, 95, 104, 97, 110, 100, 108,
101, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 171, 205, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 20, 99, 111, 109, 112, 105, 108,
97, 116, 105, 111, 110, 95, 109, 101, 116, 97, 100, 97, 116, 97, 9, 0, 3, 50,
46, 48, 3, 50, 46, 49, 0, 1, 4, 0, 1, 5, 11, 0, 11, 1, 11, 2,
17, 1, 2, 2, 1, 4, 0, 7, 19, 10, 0, 17, 3, 12, 3, 14, 3, 17,
4, 12, 4, 14, 4, 12, 5, 11, 0, 11, 5, 10, 2, 17, 5, 14, 4, 11,
1, 11, 2, 17, 1, 11, 3, 17, 6, 2, 0,
]
});

#[rustfmt::skip]
pub static MODULE_FRAMEWORK_USECASES_RESOURCE_GROUPS_EXAMPLE: Lazy<Vec<u8>> = Lazy::new(|| {
vec![
Expand Down Expand Up @@ -1608,6 +1643,7 @@ pub static MODULES_FRAMEWORK_USECASES: Lazy<Vec<Vec<u8>>> = Lazy::new(|| { vec![
MODULE_FRAMEWORK_USECASES_COIN_EXAMPLE.to_vec(),
MODULE_FRAMEWORK_USECASES_FUNGIBLE_ASSET_EXAMPLE.to_vec(),
MODULE_FRAMEWORK_USECASES_OBJECTS.to_vec(),
MODULE_FRAMEWORK_USECASES_PERMISSIONED_TRANSFER.to_vec(),
MODULE_FRAMEWORK_USECASES_RESOURCE_GROUPS_EXAMPLE.to_vec(),
MODULE_FRAMEWORK_USECASES_TOKEN_V1.to_vec(),
]});
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::fungible_asset;
use aptos_framework::permissioned_signer;

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);

fungible_asset::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 60ce91a

Please sign in to comment.