diff --git a/Cargo.lock b/Cargo.lock index 1894c50a4..7e2b0c6b6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4543,6 +4543,7 @@ dependencies = [ "polimec-common-test-utils", "polimec-receiver", "polimec-runtime", + "polimec-xcm-executor", "polkadot-core-primitives", "polkadot-parachain-primitives", "polkadot-primitives", diff --git a/integration-tests/Cargo.toml b/integration-tests/Cargo.toml index 56c1b883b..70ba1662b 100644 --- a/integration-tests/Cargo.toml +++ b/integration-tests/Cargo.toml @@ -20,6 +20,7 @@ scale-info = { workspace = true, features = ["derive"] } # Local polimec-receiver.workspace = true +polimec-xcm-executor.workspace = true macros.workspace = true polimec-common.workspace = true polimec-common-test-utils.workspace = true diff --git a/integration-tests/src/tests/xcm_config.rs b/integration-tests/src/tests/xcm_config.rs index 94a28b2d7..ba1615887 100644 --- a/integration-tests/src/tests/xcm_config.rs +++ b/integration-tests/src/tests/xcm_config.rs @@ -110,4 +110,4 @@ fn execution_fees_go_to_treasury() { assert_reserve_asset_fee_goes_to_treasury(usdt_amount); assert_reserve_asset_fee_goes_to_treasury(usdc_amount); assert_plmc_fee_goes_to_treasury(); -} +} \ No newline at end of file diff --git a/justfile b/justfile index 20668115b..8c45bf550 100644 --- a/justfile +++ b/justfile @@ -58,7 +58,7 @@ benchmark-runtime chain="polimec-paseo-local" pallet="pallet-elections-phragmen" # src: https://github.com/paritytech/polkadot-sdk/blob/bc2e5e1fe26e2c2c8ee766ff9fe7be7e212a0c62/substrate/frame/nfts/src/weights.rs # Run the Runtime benchmarks for a specific pallet benchmark-pallet chain="polimec-paseo-local" pallet="pallet-dispenser": - cargo run --features runtime-benchmarks --release -p polimec-node benchmark pallet \ + cargo run --features runtime-benchmarks --profile=production -p polimec-node benchmark pallet \ --chain={{ chain }} \ --steps=50 \ --repeat=20 \ diff --git a/pallets/funding/src/benchmarking.rs b/pallets/funding/src/benchmarking.rs index 7d9929bd9..88f808207 100644 --- a/pallets/funding/src/benchmarking.rs +++ b/pallets/funding/src/benchmarking.rs @@ -3340,6 +3340,107 @@ mod benchmarks { ); } + #[benchmark] + fn do_handle_channel_open_request() { + // setup + let mut inst = BenchInstantiator::::new(None); + ::SetPrices::set_prices(); + + let issuer = account::>("issuer", 0, 0); + + let project_metadata = default_project_metadata::(issuer.clone()); + let project_id = inst.create_finished_project( + project_metadata.clone(), + issuer.clone(), + default_evaluations::(), + default_bids::(), + default_community_contributions::(), + vec![], + ); + + let settlement_block = inst.get_update_block(project_id, &UpdateType::StartSettlement).unwrap(); + inst.jump_to_block(settlement_block); + + inst.settle_project(project_id).unwrap(); + + let jwt = get_mock_jwt_with_cid( + issuer.clone(), + InvestorType::Institutional, + generate_did_from_account(issuer.clone()), + project_metadata.clone().policy_ipfs_cid.unwrap(), + ); + + crate::Pallet::::start_pallet_migration( + RawOrigin::Signed(issuer.clone()).into(), + jwt.clone(), + project_id, + 6969u32.into(), + ) + .unwrap(); + + #[block] + { + crate::Pallet::::do_handle_channel_open_request(Instruction::HrmpNewChannelOpenRequest { + sender: 6969u32, + max_message_size: 102_400u32, + max_capacity: 1000, + }) + .unwrap(); + } + } + + #[benchmark] + fn do_handle_channel_accepted() { + // setup + let mut inst = BenchInstantiator::::new(None); + ::SetPrices::set_prices(); + + let issuer = account::>("issuer", 0, 0); + + let project_metadata = default_project_metadata::(issuer.clone()); + let project_id = inst.create_finished_project( + project_metadata.clone(), + issuer.clone(), + default_evaluations::(), + default_bids::(), + default_community_contributions::(), + vec![], + ); + + let settlement_block = inst.get_update_block(project_id, &UpdateType::StartSettlement).unwrap(); + inst.jump_to_block(settlement_block); + + inst.settle_project(project_id).unwrap(); + + let jwt = get_mock_jwt_with_cid( + issuer.clone(), + InvestorType::Institutional, + generate_did_from_account(issuer.clone()), + project_metadata.clone().policy_ipfs_cid.unwrap(), + ); + + crate::Pallet::::start_pallet_migration( + RawOrigin::Signed(issuer.clone()).into(), + jwt.clone(), + project_id, + 6969u32.into(), + ) + .unwrap(); + + crate::Pallet::::do_handle_channel_open_request(Instruction::HrmpNewChannelOpenRequest { + sender: 6969u32, + max_message_size: 102_400u32, + max_capacity: 1000, + }) + .unwrap(); + + #[block] + { + crate::Pallet::::do_handle_channel_accepted(Instruction::HrmpChannelAccepted { recipient: 6969u32 }) + .unwrap(); + } + } + #[cfg(test)] mod tests { use super::*; @@ -3604,5 +3705,19 @@ mod benchmarks { assert_ok!(PalletFunding::::test_confirm_pallet_migrations()); }); } + + #[test] + fn bench_do_handle_channel_open_request() { + new_test_ext().execute_with(|| { + assert_ok!(PalletFunding::::test_do_handle_channel_open_request()); + }); + } + + #[test] + fn bench_do_handle_channel_accepted() { + new_test_ext().execute_with(|| { + assert_ok!(PalletFunding::::test_do_handle_channel_accepted()); + }); + } } }