Skip to content
This repository has been archived by the owner on May 21, 2024. It is now read-only.

Commit

Permalink
fix: pallet_contract benchmarks
Browse files Browse the repository at this point in the history
  • Loading branch information
José Molina committed Nov 22, 2023
1 parent 7f9baed commit 868dcac
Show file tree
Hide file tree
Showing 4 changed files with 726 additions and 605 deletions.
106 changes: 106 additions & 0 deletions integration-tests/asset-conversion/0_swap.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
---
settings:
chains:
trappist_parachain: &trappist_parachain
wsPort: 9920
paraId: 2000
variables:
system:
assets_pallet_instance: &assets_pallet_instance 41
assets:
hop:
# multilocation within trappist of HOP
multilocation: &hop_multilocation { parents: 0, interior: Here }
local_asset:
id: &local_asset_id 200
name: &local_asset_name "LocalAsset"
symbol: &local_asset_symbol "LAS"
decimals: &local_asset_decimals 10
min_balance: &local_asset_min_balance 1000000000
total_supply: &local_asset_total_supply 250000000000000
# multilocation within trappist of the newly created asset
multilocation: &local_asset_multilocation { x1: { parents: 0, interior: { pallet_instance: *assets_pallet_instance, general_index: *local_asset_id } } }
chains:
trappist_parachain:
signer: &tp_signer //Alice
wallet: &tp_wallet 5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY
swap:
hop_liquidity: &hop_liquidity 1000000
hop_swap_amount: &hop_swap_amount 100
local_asset_liquidity: &local_asset_liquidity 1000000
local_asset_amount: &local_asset_amount 200

tests:
- name: Swap local assets
describes:
- name: Swapping
its:
- name: DEPENDENCY | Create a local asset
actions:
- extrinsics:
- chain: *trappist_parachain
signer: *tp_signer
pallet: assets
call: create
args: [
*local_asset_id,
{id: *tp_wallet},
*local_asset_min_balance
]
events:
- name: assets.Created
- name: DEPENDENCY | Set new asset's metadata
actions:
- extrinsics:
- chain: *trappist_parachain
signer: *tp_signer
pallet: assets
call: setMetadata
args: [
*local_asset_id,
*local_asset_name,
*local_asset_symbol,
*local_asset_decimals
]
- name: DEPENDENCY | Mint new asset
actions:
- extrinsics:
# Mint total supply to owner
- chain: *trappist_parachain
signer: *tp_signer
pallet: assets
call: mint
args:
- *local_asset_id
- *tp_wallet
- *local_asset_total_supply
events:
- name: assets.Issued
- name: Configure the asset pool
actions:
- extrinsics:
- chain: *trappist_parachain
signer: *tp_signer
pallet: asset_conversion
call: create_pool
args: [
*hop_multilocation, # first asset
*local_asset_multilocation # second asset
]
- name: Fill the pool
actions:
- extrinsics:
- chain: *trappist_parachain
signer: *tp_signer
pallet: asset_conversion
call: add_liquidity
args: [
*hop_multilocation, # first asset
*local_asset_multilocation, # second asset
*hop_liquidity, # desired amount for first asset
*local_asset_liquidity, # desired amount for second asset
*hop_liquidity, # minimum amount for first asset
*local_asset_liquidity, # minimum amount for second asset
*tp_wallet # mint LP tokens to this account
]

4 changes: 1 addition & 3 deletions runtime/stout/src/contracts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ use frame_support::{
parameter_types,
traits::{ConstU32, Nothing},
};
#[cfg(feature = "runtime-benchmarks")]
use pallet_contracts::NoopMigration;
use pallet_contracts::{
weights::SubstrateWeight, Config, DebugInfo, DefaultAddressGenerator, Frame, Schedule,
};
Expand Down Expand Up @@ -73,7 +71,7 @@ impl Config for Runtime {
#[cfg(not(feature = "runtime-benchmarks"))]
type Migrations = ();
#[cfg(feature = "runtime-benchmarks")]
type Migrations = (NoopMigration<1>, NoopMigration<2>);
type Migrations = pallet_contracts::migration::codegen::BenchMigrations;
type MaxDelegateDependencies = ConstU32<32>;
type CodeHashLockupDepositPercent = CodeHashLockupDepositPercent;
type Debug = ();
Expand Down
4 changes: 1 addition & 3 deletions runtime/trappist/src/contracts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ use frame_support::{
parameter_types,
traits::{ConstBool, ConstU32, Nothing},
};
#[cfg(feature = "runtime-benchmarks")]
use pallet_contracts::NoopMigration;
use pallet_contracts::{
migration::{v13, v14, v15},
Config, DebugInfo, DefaultAddressGenerator, Frame, Schedule,
Expand Down Expand Up @@ -73,7 +71,7 @@ impl Config for Runtime {
#[cfg(not(feature = "runtime-benchmarks"))]
type Migrations = (v13::Migration<Self>, v14::Migration<Self, Balances>, v15::Migration<Self>);
#[cfg(feature = "runtime-benchmarks")]
type Migrations = (NoopMigration<1>, NoopMigration<2>);
type Migrations = pallet_contracts::migration::codegen::BenchMigrations;
type MaxDelegateDependencies = ConstU32<32>;
type CodeHashLockupDepositPercent = CodeHashLockupDepositPercent;
type Debug = ();
Expand Down
Loading

0 comments on commit 868dcac

Please sign in to comment.