Calibrate distance `MAX_EVALUATIONS_PER_SESSION`
After !219 (merged), on_new_session
hook in distance pallet will perform non-trivial operation including do_valid_distance_status
and on_valid_distance_status
cascade with try_add_membership
/try_renew_membership
branches. This can be done at most MAX_EVALUATIONS_PER_SESSION
times, so this value should be set carefully to avoid spending more weights than a block has.
@bgallois pointed me that for session pallet, the whole weight of a block is consumed in on_initialize
, no matter what is really consumed by rotate_session
: https://github.com/paritytech/polkadot-sdk/blob/ac303406ffc0b1478b53d236a7983c31755717bc/substrate/frame/session/src/lib.rs#L566C5-L566C37
We would prefer to avoid that and only reserve a known worst-case weight that is known not to exceed the total available.