Skip to content

Commit

Permalink
fix benchmarks
Browse files Browse the repository at this point in the history
  • Loading branch information
xlc committed Aug 15, 2024
1 parent 092572a commit ee9d484
Show file tree
Hide file tree
Showing 9 changed files with 27 additions and 128 deletions.
40 changes: 2 additions & 38 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -46,49 +46,13 @@ build-benches:
cargo bench --locked --no-run --features wasm-bench --package module-evm
cargo bench --locked --no-run --features wasm-bench --package runtime-common

.PHONY: build-release
build-release:
cargo build --locked --features with-all-runtime --profile production --bin acala

.PHONY: build-mandala-release
build-mandala-release:
cargo build --locked --features with-mandala-runtime --profile production --bin acala

.PHONY: build-karura-release
build-karura-release:
cargo build --locked --features with-karura-runtime --profile production --bin acala

.PHONY: build-acala-release
build-acala-release:
cargo build --locked --features with-acala-runtime --profile production --bin acala

.PHONY: build-mandala-internal-release
build-mandala-internal-release:
cargo build --locked --features with-mandala-runtime --release --bin acala

.PHONY: build-karura-internal-release
build-karura-internal-release:
cargo build --locked --features with-karura-runtime --release --bin acala

.PHONY: build-acala-internal-release
build-acala-internal-release:
cargo build --locked --features with-acala-runtime --release --bin acala

.PHONY: check
check: githooks
SKIP_WASM_BUILD= cargo check --features with-mandala-runtime

.PHONY: check
check-karura: githooks
SKIP_WASM_BUILD= cargo check --features with-karura-runtime

.PHONY: check
check-acala: githooks
SKIP_WASM_BUILD= cargo check --features with-acala-runtime
SKIP_WASM_BUILD= cargo check

.PHONY: check-tests
check-tests: githooks
SKIP_WASM_BUILD= cargo check --features with-all-runtime --tests --all
SKIP_WASM_BUILD= cargo check --tests --all

.PHONY: check-all
check-all: check-runtimes check-benchmarks check-tests check-integration-tests
Expand Down
3 changes: 0 additions & 3 deletions runtime/acala/src/benchmarking/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,6 @@ pub mod auction {
pub mod authority {
include!("../../../mandala/src/benchmarking/authority.rs");
}
pub mod oracle {
include!("../../../mandala/src/benchmarking/oracle.rs");
}
pub mod tokens {
include!("../../../mandala/src/benchmarking/tokens.rs");
}
Expand Down
2 changes: 1 addition & 1 deletion runtime/acala/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2028,7 +2028,6 @@ mod benches {
[orml_vesting, benchmarking::vesting]
[orml_auction, benchmarking::auction]
[orml_authority, benchmarking::authority]
[orml_oracle, benchmarking::oracle]
[nutsfinance_stable_asset, benchmarking::nutsfinance_stable_asset]
[module_idle_scheduler, benchmarking::idle_scheduler]
[module_aggregated_dex, benchmarking::aggregated_dex]
Expand All @@ -2038,6 +2037,7 @@ mod benches {
// frame_benchmarking::define_benchmarks!(
// // XCM
// [pallet_xcm, PalletXcmExtrinsicsBenchmark::<Runtime>]
// // TODO: add oracle
// );
}

Expand Down
3 changes: 0 additions & 3 deletions runtime/karura/src/benchmarking/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,6 @@ pub mod auction {
pub mod authority {
include!("../../../mandala/src/benchmarking/authority.rs");
}
pub mod oracle {
include!("../../../mandala/src/benchmarking/oracle.rs");
}
pub mod tokens {
include!("../../../mandala/src/benchmarking/tokens.rs");
}
Expand Down
2 changes: 1 addition & 1 deletion runtime/karura/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2057,7 +2057,6 @@ mod benches {
[orml_vesting, benchmarking::vesting]
[orml_auction, benchmarking::auction]
[orml_authority, benchmarking::authority]
[orml_oracle, benchmarking::oracle]
[nutsfinance_stable_asset, benchmarking::nutsfinance_stable_asset]
[module_idle_scheduler, benchmarking::idle_scheduler]
[module_aggregated_dex, benchmarking::aggregated_dex]
Expand All @@ -2066,6 +2065,7 @@ mod benches {
// frame_benchmarking::define_benchmarks!(
// // XCM
// [pallet_xcm, PalletXcmExtrinsicsBenchmark::<Runtime>]
// // TODO: add oracle
// );
}

Expand Down
41 changes: 23 additions & 18 deletions runtime/mandala/src/benchmarking/authority.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,57 +18,64 @@

use crate::{AccountId, Authority, AuthoritysOriginId, BlockNumber, Runtime, RuntimeCall, RuntimeOrigin, System};

use parity_scale_codec::Encode;
use sp_runtime::traits::Hash;
use sp_std::prelude::*;

use frame_support::{
dispatch::GetDispatchInfo,
traits::{schedule::DispatchTime, OriginTrait},
traits::{schedule::DispatchTime, Bounded, OriginTrait},
};
use frame_system::RawOrigin;
use orml_benchmarking::{runtime_benchmarks, whitelisted_caller};

fn runtime_call() -> Box<RuntimeCall> {
let call = RuntimeCall::System(frame_system::Call::remark { remark: vec![] });
Box::new(call)
}

fn bounded_call(call: RuntimeCall) -> Box<Bounded<RuntimeCall, <Runtime as frame_system::Config>::Hashing>> {
let encoded_call = call.encode();
Box::new(Bounded::Inline(encoded_call.try_into().unwrap()))
}

runtime_benchmarks! {
{ Runtime, orml_authority }

// dispatch a dispatchable as other origin
dispatch_as {
let ensure_root_call = RuntimeCall::System(frame_system::Call::remark { remark: vec![] });
}: _(RawOrigin::Root, AuthoritysOriginId::Root, Box::new(ensure_root_call.clone()))
}: _(RawOrigin::Root, AuthoritysOriginId::Root, runtime_call())

// schdule a dispatchable to be dispatched at later block.
schedule_dispatch_without_delay {
let ensure_root_call = RuntimeCall::System(frame_system::Call::remark { remark: vec![] });
let call = RuntimeCall::Authority(orml_authority::Call::dispatch_as {
as_origin: AuthoritysOriginId::Root,
call: Box::new(ensure_root_call.clone()),
call: runtime_call(),
});
}: schedule_dispatch(RawOrigin::Root, DispatchTime::At(2), 0, false, Box::new(call.clone()))
}: schedule_dispatch(RawOrigin::Root, DispatchTime::At(2), 0, false, bounded_call(call))

// schdule a dispatchable to be dispatched at later block.
// ensure that the delay is reached when scheduling
schedule_dispatch_with_delay {
let ensure_root_call = RuntimeCall::System(frame_system::Call::remark { remark: vec![] });
let call = RuntimeCall::Authority(orml_authority::Call::dispatch_as {
as_origin: AuthoritysOriginId::Root,
call: Box::new(ensure_root_call.clone()),
call: runtime_call(),
});
}: schedule_dispatch(RawOrigin::Root, DispatchTime::At(2), 0, true, Box::new(call.clone()))
}: schedule_dispatch(RawOrigin::Root, DispatchTime::At(2), 0, true, bounded_call(call))

// fast track a scheduled dispatchable.
fast_track_scheduled_dispatch {
let ensure_root_call = RuntimeCall::System(frame_system::Call::remark { remark: vec![] });
let call = RuntimeCall::Authority(orml_authority::Call::dispatch_as {
as_origin: AuthoritysOriginId::Root,
call: Box::new(ensure_root_call.clone()),
call: runtime_call(),
});
System::set_block_number(1u32);
Authority::schedule_dispatch(
RuntimeOrigin::root(),
DispatchTime::At(2),
0,
true,
Box::new(call.clone())
bounded_call(call)
)?;
let schedule_origin = {
let origin: <Runtime as frame_system::Config>::RuntimeOrigin = From::from(RuntimeOrigin::root());
Expand All @@ -85,18 +92,17 @@ runtime_benchmarks! {

// delay a scheduled dispatchable.
delay_scheduled_dispatch {
let ensure_root_call = RuntimeCall::System(frame_system::Call::remark { remark: vec![] });
let call = RuntimeCall::Authority(orml_authority::Call::dispatch_as {
as_origin: AuthoritysOriginId::Root,
call: Box::new(ensure_root_call.clone()),
call: runtime_call(),
});
System::set_block_number(1u32);
Authority::schedule_dispatch(
RuntimeOrigin::root(),
DispatchTime::At(2),
0,
true,
Box::new(call.clone())
bounded_call(call)
)?;
let schedule_origin = {
let origin: <Runtime as frame_system::Config>::RuntimeOrigin = From::from(RuntimeOrigin::root());
Expand All @@ -113,18 +119,17 @@ runtime_benchmarks! {

// cancel a scheduled dispatchable
cancel_scheduled_dispatch {
let ensure_root_call = RuntimeCall::System(frame_system::Call::remark { remark: vec![] });
let call = RuntimeCall::Authority(orml_authority::Call::dispatch_as {
as_origin: AuthoritysOriginId::Root,
call: Box::new(ensure_root_call.clone()),
call: runtime_call(),
});
System::set_block_number(1u32);
Authority::schedule_dispatch(
RuntimeOrigin::root(),
DispatchTime::At(2),
0,
true,
Box::new(call.clone())
bounded_call(call)
)?;
let schedule_origin = {
let origin: <Runtime as frame_system::Config>::RuntimeOrigin = From::from(RuntimeOrigin::root());
Expand Down
1 change: 0 additions & 1 deletion runtime/mandala/src/benchmarking/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ pub mod transaction_payment;
// orml benchmarking
pub mod auction;
pub mod authority;
pub mod oracle;
pub mod tokens;
pub mod vesting;

Expand Down
62 changes: 0 additions & 62 deletions runtime/mandala/src/benchmarking/oracle.rs

This file was deleted.

1 change: 0 additions & 1 deletion runtime/mandala/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2215,7 +2215,6 @@ mod benches {
[orml_vesting, benchmarking::vesting]
[orml_auction, benchmarking::auction]
[orml_authority, benchmarking::authority]
[orml_oracle, benchmarking::oracle]
[nutsfinance_stable_asset, benchmarking::nutsfinance_stable_asset]
[module_idle_scheduler, benchmarking::idle_scheduler]
[module_aggregated_dex, benchmarking::aggregated_dex]
Expand Down

0 comments on commit ee9d484

Please sign in to comment.