diff --git a/Makefile b/Makefile index acb1a3374d..81a57aa5ec 100644 --- a/Makefile +++ b/Makefile @@ -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 diff --git a/runtime/acala/src/benchmarking/mod.rs b/runtime/acala/src/benchmarking/mod.rs index 9128b1b343..c5d41b4d72 100644 --- a/runtime/acala/src/benchmarking/mod.rs +++ b/runtime/acala/src/benchmarking/mod.rs @@ -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"); } diff --git a/runtime/acala/src/lib.rs b/runtime/acala/src/lib.rs index 747ec26f25..4daf4bc5ff 100644 --- a/runtime/acala/src/lib.rs +++ b/runtime/acala/src/lib.rs @@ -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] @@ -2038,6 +2037,7 @@ mod benches { // frame_benchmarking::define_benchmarks!( // // XCM // [pallet_xcm, PalletXcmExtrinsicsBenchmark::] + // // TODO: add oracle // ); } diff --git a/runtime/karura/src/benchmarking/mod.rs b/runtime/karura/src/benchmarking/mod.rs index df076bf69d..520b305a38 100644 --- a/runtime/karura/src/benchmarking/mod.rs +++ b/runtime/karura/src/benchmarking/mod.rs @@ -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"); } diff --git a/runtime/karura/src/lib.rs b/runtime/karura/src/lib.rs index 8c9f9cc0d8..edd0b2dc89 100644 --- a/runtime/karura/src/lib.rs +++ b/runtime/karura/src/lib.rs @@ -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] @@ -2066,6 +2065,7 @@ mod benches { // frame_benchmarking::define_benchmarks!( // // XCM // [pallet_xcm, PalletXcmExtrinsicsBenchmark::] + // // TODO: add oracle // ); } diff --git a/runtime/mandala/src/benchmarking/authority.rs b/runtime/mandala/src/benchmarking/authority.rs index 84662ac34b..61115af876 100644 --- a/runtime/mandala/src/benchmarking/authority.rs +++ b/runtime/mandala/src/benchmarking/authority.rs @@ -18,49 +18,56 @@ 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 { + let call = RuntimeCall::System(frame_system::Call::remark { remark: vec![] }); + Box::new(call) +} + +fn bounded_call(call: RuntimeCall) -> Box::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( @@ -68,7 +75,7 @@ runtime_benchmarks! { DispatchTime::At(2), 0, true, - Box::new(call.clone()) + bounded_call(call) )?; let schedule_origin = { let origin: ::RuntimeOrigin = From::from(RuntimeOrigin::root()); @@ -85,10 +92,9 @@ 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( @@ -96,7 +102,7 @@ runtime_benchmarks! { DispatchTime::At(2), 0, true, - Box::new(call.clone()) + bounded_call(call) )?; let schedule_origin = { let origin: ::RuntimeOrigin = From::from(RuntimeOrigin::root()); @@ -113,10 +119,9 @@ 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( @@ -124,7 +129,7 @@ runtime_benchmarks! { DispatchTime::At(2), 0, true, - Box::new(call.clone()) + bounded_call(call) )?; let schedule_origin = { let origin: ::RuntimeOrigin = From::from(RuntimeOrigin::root()); diff --git a/runtime/mandala/src/benchmarking/mod.rs b/runtime/mandala/src/benchmarking/mod.rs index 6de441f595..dc36a08d9f 100644 --- a/runtime/mandala/src/benchmarking/mod.rs +++ b/runtime/mandala/src/benchmarking/mod.rs @@ -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; diff --git a/runtime/mandala/src/benchmarking/oracle.rs b/runtime/mandala/src/benchmarking/oracle.rs deleted file mode 100644 index 476fb652ea..0000000000 --- a/runtime/mandala/src/benchmarking/oracle.rs +++ /dev/null @@ -1,62 +0,0 @@ -// This file is part of Acala. - -// Copyright (C) 2020-2024 Acala Foundation. -// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0 - -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License -// along with this program. If not, see . - -use crate::{AcalaDataProvider, AcalaOracle, Price, Runtime, RuntimeOrigin, System}; - -use super::get_benchmarking_collateral_currency_ids; -use frame_support::traits::OnFinalize; -use orml_benchmarking::runtime_benchmarks_instance; -use sp_runtime::traits::One; -use sp_std::vec; - -runtime_benchmarks_instance! { - { Runtime, orml_oracle, AcalaDataProvider } - - // feed values - feed_values { - let c in 0 .. get_benchmarking_collateral_currency_ids().len() as u32; - let currency_ids = get_benchmarking_collateral_currency_ids(); - let mut values = vec![]; - - for i in 0 .. c { - values.push((currency_ids[i as usize], Price::one())); - } - }: _(RuntimeOrigin::root(), values.try_into().unwrap()) - - on_finalize { - let currency_ids = get_benchmarking_collateral_currency_ids(); - let mut values = vec![]; - - for currency_id in currency_ids { - values.push((currency_id, Price::one())); - } - System::set_block_number(1); - AcalaOracle::feed_values(RuntimeOrigin::root(), values.try_into().unwrap())?; - }: { - AcalaOracle::on_finalize(System::block_number()); - } -} - -#[cfg(test)] -mod tests { - use super::*; - use crate::benchmarking::utils::tests::new_test_ext; - use orml_benchmarking::impl_benchmark_test_suite; - - impl_benchmark_test_suite!(new_test_ext(),); -} diff --git a/runtime/mandala/src/lib.rs b/runtime/mandala/src/lib.rs index 8aa8905cb0..264669a2b2 100644 --- a/runtime/mandala/src/lib.rs +++ b/runtime/mandala/src/lib.rs @@ -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]