Skip to content

Commit

Permalink
add benchmarks and weights for revert_outbound_transfer
Browse files Browse the repository at this point in the history
  • Loading branch information
kdembler committed Jun 4, 2024
1 parent 137e386 commit 4405f14
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 13 deletions.
38 changes: 38 additions & 0 deletions runtime-modules/argo-bridge/src/benchmarking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,37 @@ benchmarks! {
RawEvent::OutboundTransferRequested(transfer_id, sender, dest_account, transfer_amount, fee).into());
}

revert_outbound_transfer{
let fee: BalanceOf<T> = 10u32.into();
let pauser_acount = T::AccountId::create_account_id(1u32);
let operator_account = T::AccountId::create_account_id(1u32);
let remote_chains: Vec<u32> = (0..MAX_REMOTE_CHAINS).collect();
let parameters = BridgeConstraints {
operator_account: Some(operator_account.clone()),
pauser_accounts: Some(vec![pauser_acount.clone()]),
bridging_fee: Some(fee),
thawn_duration: Some(1u32.into()),
remote_chains: Some(BoundedVec::try_from(remote_chains).unwrap())
};

ArgoBridge::<T>::update_bridge_constrains(
RawOrigin::Root.into(),
parameters
).unwrap();
activate_bridge::<T>(&pauser_acount, &operator_account);

let revert_amount: u32 = 1030u32;
set_bridge_mint_allowance::<T>(revert_amount.into(), fee);

let transfer_id = 1u64;
let rationale = "test".as_bytes().to_vec();
let revert_account = T::AccountId::create_account_id(2u32);
}: _(RawOrigin::Signed(operator_account), transfer_id, revert_account.clone(), revert_amount.into(), rationale.clone())
verify {
assert_last_event::<T>(
RawEvent::OutboundTransferReverted(transfer_id, revert_account, revert_amount.into(), rationale).into());
}


// Worst case scenario:
// - max number of remote chains being use
Expand Down Expand Up @@ -295,6 +326,13 @@ mod tests {
});
}

#[test]
fn test_revert_outbound_transfer() {
with_test_externalities(|| {
assert_ok!(ArgoBridge::test_benchmark_revert_outbound_transfer());
});
}

#[test]
fn test_finalize_inbound_transfer() {
with_test_externalities(|| {
Expand Down
26 changes: 13 additions & 13 deletions runtime-modules/argo-bridge/src/weights.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
//! Autogenerated weights for argo_bridge
//!
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev
//! DATE: 2024-05-31, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]`
//! DATE: 2024-06-03, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]`
//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("prod-test"), DB CACHE: 1024

// Executed Command:
Expand Down Expand Up @@ -71,8 +71,8 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
// Proof Size summary in bytes:
// Measured: `430`
// Estimated: `11104`
// Minimum execution time: 998_107 nanoseconds.
Weight::from_parts(1_038_838_000, 0u64)
// Minimum execution time: 995_959 nanoseconds.
Weight::from_parts(1_008_789_000, 0u64)
.saturating_add(Weight::from_parts(0, 11104))
.saturating_add(T::DbWeight::get().reads(6_u64))
.saturating_add(T::DbWeight::get().writes(3_u64))
Expand All @@ -91,8 +91,8 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
// Proof Size summary in bytes:
// Measured: `473`
// Estimated: `9627`
// Minimum execution time: 883_138 nanoseconds.
Weight::from_parts(900_668_000, 0u64)
// Minimum execution time: 880_220 nanoseconds.
Weight::from_parts(895_010_000, 0u64)
.saturating_add(Weight::from_parts(0, 9627))
.saturating_add(T::DbWeight::get().reads(5_u64))
.saturating_add(T::DbWeight::get().writes(2_u64))
Expand All @@ -105,8 +105,8 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
// Proof Size summary in bytes:
// Measured: `498`
// Estimated: `1806`
// Minimum execution time: 371_039 nanoseconds.
Weight::from_parts(382_129_000, 0u64)
// Minimum execution time: 371_270 nanoseconds.
Weight::from_parts(375_040_000, 0u64)
.saturating_add(Weight::from_parts(0, 1806))
.saturating_add(T::DbWeight::get().reads(1_u64))
.saturating_add(T::DbWeight::get().writes(1_u64))
Expand All @@ -121,8 +121,8 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
// Proof Size summary in bytes:
// Measured: `498`
// Estimated: `3295`
// Minimum execution time: 402_659 nanoseconds.
Weight::from_parts(420_319_000, 0u64)
// Minimum execution time: 407_650 nanoseconds.
Weight::from_parts(440_379_000, 0u64)
.saturating_add(Weight::from_parts(0, 3295))
.saturating_add(T::DbWeight::get().reads(2_u64))
.saturating_add(T::DbWeight::get().writes(1_u64))
Expand All @@ -135,8 +135,8 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
// Proof Size summary in bytes:
// Measured: `173`
// Estimated: `3007`
// Minimum execution time: 412_269 nanoseconds.
Weight::from_parts(422_459_000, 0u64)
// Minimum execution time: 415_480 nanoseconds.
Weight::from_parts(421_560_000, 0u64)
.saturating_add(Weight::from_parts(0, 3007))
.saturating_add(T::DbWeight::get().reads(2_u64))
.saturating_add(T::DbWeight::get().writes(1_u64))
Expand All @@ -155,8 +155,8 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
// Proof Size summary in bytes:
// Measured: `0`
// Estimated: `0`
// Minimum execution time: 293_519 nanoseconds.
Weight::from_parts(298_009_000, 0u64)
// Minimum execution time: 293_260 nanoseconds.
Weight::from_parts(298_360_000, 0u64)
.saturating_add(Weight::from_parts(0, 0))
.saturating_add(T::DbWeight::get().writes(5_u64))
}
Expand Down

0 comments on commit 4405f14

Please sign in to comment.