Skip to content

Commit

Permalink
ensure on_initialize_with_bump_era under block weight limit (#2816)
Browse files Browse the repository at this point in the history
* add test for on_initialize_with_bump_era to ensure the weight within block weight limit

* reduce ProcessRedeemRequestsLimit
  • Loading branch information
xlc committed Oct 14, 2024
1 parent da410b3 commit 46abebd
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 5 deletions.
2 changes: 0 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
cargo-features = ["resolver"]

[workspace]
members = [
"node",
Expand Down
12 changes: 11 additions & 1 deletion runtime/acala/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1592,7 +1592,7 @@ impl module_homa::Config for Runtime {
type XcmInterface = XcmInterface;
type WeightInfo = weights::module_homa::WeightInfo<Runtime>;
type NominationsProvider = NomineesElection;
type ProcessRedeemRequestsLimit = ConstU32<2_000>;
type ProcessRedeemRequestsLimit = ConstU32<1_000>;
}

parameter_types! {
Expand Down Expand Up @@ -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::<Runtime>::on_initialize_with_bump_era(
<Runtime as module_homa::Config>::ProcessRedeemRequestsLimit::get(),
);
let block_weight = RuntimeBlockWeights::get().max_block.div(3).mul(2);
assert!(weight.all_lt(block_weight));
}
}
12 changes: 11 additions & 1 deletion runtime/karura/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1617,7 +1617,7 @@ impl module_homa::Config for Runtime {
type XcmInterface = XcmInterface;
type WeightInfo = weights::module_homa::WeightInfo<Runtime>;
type NominationsProvider = NomineesElection;
type ProcessRedeemRequestsLimit = ConstU32<2_000>;
type ProcessRedeemRequestsLimit = ConstU32<1_000>;
}

parameter_types! {
Expand Down Expand Up @@ -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::<Runtime>::on_initialize_with_bump_era(
<Runtime as module_homa::Config>::ProcessRedeemRequestsLimit::get(),
);
let block_weight = RuntimeBlockWeights::get().max_block.div(3).mul(2);
assert!(weight.all_lt(block_weight));
}
}
12 changes: 11 additions & 1 deletion runtime/mandala/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1452,7 +1452,7 @@ impl module_homa::Config for Runtime {
type XcmInterface = XcmInterface;
type WeightInfo = weights::module_homa::WeightInfo<Runtime>;
type NominationsProvider = NomineesElection;
type ProcessRedeemRequestsLimit = ConstU32<2_000>;
type ProcessRedeemRequestsLimit = ConstU32<1_000>;
}

parameter_types! {
Expand Down Expand Up @@ -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::<Runtime>::on_initialize_with_bump_era(
<Runtime as module_homa::Config>::ProcessRedeemRequestsLimit::get(),
);
let block_weight = RuntimeBlockWeights::get().max_block.div(3).mul(2);
assert!(weight.all_lt(block_weight));
}
}

0 comments on commit 46abebd

Please sign in to comment.