From 46abebd4ce8e8f66f5c9d3ecb4a5d63ebea1c049 Mon Sep 17 00:00:00 2001 From: Xiliang Chen Date: Mon, 14 Oct 2024 14:57:58 +1300 Subject: [PATCH] ensure on_initialize_with_bump_era under block weight limit (#2816) * add test for on_initialize_with_bump_era to ensure the weight within block weight limit * reduce ProcessRedeemRequestsLimit --- Cargo.toml | 2 -- runtime/acala/src/lib.rs | 12 +++++++++++- runtime/karura/src/lib.rs | 12 +++++++++++- runtime/mandala/src/lib.rs | 12 +++++++++++- 4 files changed, 33 insertions(+), 5 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 360c3e69d1..e26cb7411a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,5 +1,3 @@ -cargo-features = ["resolver"] - [workspace] members = [ "node", diff --git a/runtime/acala/src/lib.rs b/runtime/acala/src/lib.rs index 8a2bd047c2..ec85a7d5f2 100644 --- a/runtime/acala/src/lib.rs +++ b/runtime/acala/src/lib.rs @@ -1592,7 +1592,7 @@ impl module_homa::Config for Runtime { type XcmInterface = XcmInterface; type WeightInfo = weights::module_homa::WeightInfo; type NominationsProvider = NomineesElection; - type ProcessRedeemRequestsLimit = ConstU32<2_000>; + type ProcessRedeemRequestsLimit = ConstU32<1_000>; } parameter_types! { @@ -2647,4 +2647,14 @@ mod tests { If the limit is too strong, maybe consider increasing the limit", ); } + + #[test] + fn check_on_initialize_with_bump_era_weight() { + use module_homa::WeightInfo; + let weight = weights::module_homa::WeightInfo::::on_initialize_with_bump_era( + ::ProcessRedeemRequestsLimit::get(), + ); + let block_weight = RuntimeBlockWeights::get().max_block.div(3).mul(2); + assert!(weight.all_lt(block_weight)); + } } diff --git a/runtime/karura/src/lib.rs b/runtime/karura/src/lib.rs index 7dab295c97..734d44fcd9 100644 --- a/runtime/karura/src/lib.rs +++ b/runtime/karura/src/lib.rs @@ -1617,7 +1617,7 @@ impl module_homa::Config for Runtime { type XcmInterface = XcmInterface; type WeightInfo = weights::module_homa::WeightInfo; type NominationsProvider = NomineesElection; - type ProcessRedeemRequestsLimit = ConstU32<2_000>; + type ProcessRedeemRequestsLimit = ConstU32<1_000>; } parameter_types! { @@ -2648,4 +2648,14 @@ mod tests { If the limit is too strong, maybe consider increasing the limit", ); } + + #[test] + fn check_on_initialize_with_bump_era_weight() { + use module_homa::WeightInfo; + let weight = weights::module_homa::WeightInfo::::on_initialize_with_bump_era( + ::ProcessRedeemRequestsLimit::get(), + ); + let block_weight = RuntimeBlockWeights::get().max_block.div(3).mul(2); + assert!(weight.all_lt(block_weight)); + } } diff --git a/runtime/mandala/src/lib.rs b/runtime/mandala/src/lib.rs index 058acb33ad..c8cfebb124 100644 --- a/runtime/mandala/src/lib.rs +++ b/runtime/mandala/src/lib.rs @@ -1452,7 +1452,7 @@ impl module_homa::Config for Runtime { type XcmInterface = XcmInterface; type WeightInfo = weights::module_homa::WeightInfo; type NominationsProvider = NomineesElection; - type ProcessRedeemRequestsLimit = ConstU32<2_000>; + type ProcessRedeemRequestsLimit = ConstU32<1_000>; } parameter_types! { @@ -2802,4 +2802,14 @@ mod tests { ); }); } + + #[test] + fn check_on_initialize_with_bump_era_weight() { + use module_homa::WeightInfo; + let weight = weights::module_homa::WeightInfo::::on_initialize_with_bump_era( + ::ProcessRedeemRequestsLimit::get(), + ); + let block_weight = RuntimeBlockWeights::get().max_block.div(3).mul(2); + assert!(weight.all_lt(block_weight)); + } }