From 7ce479626de1cc2965f3908c6f2ea5b22dfdd5af Mon Sep 17 00:00:00 2001 From: Bryan Chen Date: Mon, 14 Oct 2024 13:50:09 +1300 Subject: [PATCH 1/2] add test for on_initialize_with_bump_era to ensure the weight within block weight limit --- Cargo.toml | 2 -- runtime/acala/src/lib.rs | 10 ++++++++++ runtime/karura/src/lib.rs | 10 ++++++++++ 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index be9b92439..04bec0853 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,5 +1,3 @@ -cargo-features = ["resolver"] - [workspace] members = [ "modules/*", diff --git a/runtime/acala/src/lib.rs b/runtime/acala/src/lib.rs index b1cc16320..197a21998 100644 --- a/runtime/acala/src/lib.rs +++ b/runtime/acala/src/lib.rs @@ -2719,4 +2719,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 b98bdf3ec..b6bad2e71 100644 --- a/runtime/karura/src/lib.rs +++ b/runtime/karura/src/lib.rs @@ -2752,4 +2752,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)); + } } From 3cd966f0c976e8f4a28c7cdbc69ecbcb4dc58ee9 Mon Sep 17 00:00:00 2001 From: Bryan Chen Date: Mon, 14 Oct 2024 14:12:49 +1300 Subject: [PATCH 2/2] reduce ProcessRedeemRequestsLimit --- runtime/acala/src/lib.rs | 2 +- runtime/karura/src/lib.rs | 2 +- runtime/mandala/src/lib.rs | 12 +++++++++++- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/runtime/acala/src/lib.rs b/runtime/acala/src/lib.rs index 197a21998..dd9aaf10f 100644 --- a/runtime/acala/src/lib.rs +++ b/runtime/acala/src/lib.rs @@ -1594,7 +1594,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! { diff --git a/runtime/karura/src/lib.rs b/runtime/karura/src/lib.rs index b6bad2e71..427001785 100644 --- a/runtime/karura/src/lib.rs +++ b/runtime/karura/src/lib.rs @@ -1619,7 +1619,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! { diff --git a/runtime/mandala/src/lib.rs b/runtime/mandala/src/lib.rs index 9d2b6b327..10595e4de 100644 --- a/runtime/mandala/src/lib.rs +++ b/runtime/mandala/src/lib.rs @@ -1447,7 +1447,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! { @@ -2865,4 +2865,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)); + } }